Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When set the value of a 'val' ? #24

Closed
gbasso opened this issue Mar 17, 2014 · 1 comment
Closed

When set the value of a 'val' ? #24

gbasso opened this issue Mar 17, 2014 · 1 comment
Labels
Milestone

Comments

@gbasso
Copy link

gbasso commented Mar 17, 2014

The following code highlight an error (Assignment to final field) :

agent TransmitterAgent {
    val capacityValue : Double

    on Initialize {
        capacityValue = occurrence.parameters.get(0) as Double;
    }
}

Moreover an error occurs in the java code.

public class TransmitterAgent extends Agent {
  /**
   * Creates a new Agent of type TransmitterAgent
   */
  public TransmitterAgent(final java.util.UUID parentID) { // error
// Multiple markers at this line
//  - The blank final field capacityValue may not have been initialized
@ngaud
Copy link
Member

ngaud commented Mar 20, 2014

val capacityValue : Double = 5 this is the only way to initialize a val inside an agent. Because val keyword is mapped to a final attribute in Java, and the Agent's constructor is not accessible to the user.

The various "on initialize" must be the constructors of the agent but currently there is no easy solution to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants