Category:Elena: Difference between revisions
Content added Content deleted
Line 67: | Line 67: | ||
The assigning value can be an expression itself: |
The assigning value can be an expression itself: |
||
program = |
public program = |
||
[ |
[ |
||
console writeLine("Hello!"); writeLine("How are you?"). |
console writeLine("Hello!"); writeLine("How are you?"). |
||
Line 75: | Line 75: | ||
ELENA is a dynamic language and in normal case we may not specify the variable type: |
ELENA is a dynamic language and in normal case we may not specify the variable type: |
||
program = |
public program = |
||
[ |
[ |
||
var s := "Hello". |
var s := "Hello". |
||
Line 91: | Line 91: | ||
But it is still possible to specify the variable expected type: |
But it is still possible to specify the variable expected type: |
||
T<LiteralValue> s := "Hello". |
|||
console writeLine(s). |
console writeLine(s). |
||
Line 104: | Line 104: | ||
literal s := "Hello". |
literal s := "Hello". |
||
s := 2. |
s := T<literal>(2). |
||
Why? ELENA is a dynamic language and in most cases resolves the types in run-time. So our code will be actually |
Why? ELENA is a dynamic language and in most cases resolves the types in run-time. So our code will be actually |
||
Line 110: | Line 110: | ||
literal s := "Hello". |
literal s := "Hello". |
||
s := |
s := T<literal>(2) |
||
It is guaranteed that the result of |
It is guaranteed that the result of the cast message is an instance of LiteralValue, so if the object supports the message the conversion will be done quietly. |
||
int n := 3. |
|||
n := 3.4r. |
|||
The output will be: |
The output will be: |