All Downloads are FREE. Search and download functionalities are using the official Maven repository.

reference.language.assignments.html Maven / Gradle / Ivy




    
    Assignments
    
    

    
    

    
    

    
    
    
    

    


Assignment statements

An assignment is a statement which assigns the value of an expression to a value holder.
An assignment has the form holder = exp where exp is an expression, aka rvalue (read right value) and holder is a valid value holder, aka lvalue (read left value).
When an assignment statement is executed, the rvalue is computed and stored in the lvalue.

Assigning values to variables


Prompto infers the type of a variable from its first assignment, which is generaly desirable.
In the above example, the variable a has the type Integer.
There are however situations where you might want the type to be explicit.
In the first statement of the below example, the assigned type is Decimal, although the rvalue is an Integer.
This is in preparation of the next statement, where the rvalue is a Decimal.
Without the explicit type in the first statement, the second statement would be illegal because an Integer variable cannot hold a Decimal value.


Assigning values to list items

Prompto values are immutable by default. Therefore you cannot change the contents of a list, unless you make it explicit using the mutable keyword when creating the list.
A list item assignment has the form list[item] = exp where exp is an expression, list is a list expression and item is an Integer expression.
The item must be in the range 1 .. n where n is the number of items in the list.


Assigning values to tuple items

Assigning values to tuple items is done the same way as for lists.


Assigning values to set items

Assigning values to set items is illegal.

Assigning values to dictionary keys

Prompto values are immutable by default. Therefore you cannot change the contents of a dictionary, unless you make it explicit using the mutable keyword when creating the dictionary.
A dictionary key assignment has the form dict[key] = exp where exp is an expression, dict is a dictionary expression and key is a Text expression.

Assigning values to category object members

Prompto values are immutable by default. Therefore you cannot change a member of a category object, unless you make it explicit using the mutable keyword when creating the object.
A category member assignment has the form object.member = exp where exp is an expression, object is a category object expression and member is an attribute.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy