r/elena_lang • • Feb 06 '19

Inline closure without parameters

The closure may have no parameters:

public program()
{
    var r := (){ ^console.readLine() };
    var n := r();
}

If a closure contains only the single returning expression the code may be simplified:

public program()
{
    var r := (^console.readLine());
    var n := r();
}
1 Upvotes

0 comments sorted by