Ceylon language

Kagamin spam at here.lot
Wed Apr 13 08:27:38 PDT 2011


bearophile Wrote:

> String? name = process.args.first;
> if (exists name) {
>     writeLine("Hello " name "!");
> }
> else {
>     writeLine("Hello World!");
> }
> 
> Use of an optional value must be guarded by the if (exists ... ) construct. Therefore, NullPointerExceptions are impossible.
> 

How will it work on this code?

String? name = process.args.first;
myLibCustomEnforce(exists name);
writeLine("Hello " name "!");

> A class or interface satisfies zero or more interfaces
> 
> shared class Character(Natural utf16) 
>     extends Object()
>     satisfies Ordinal & Comparable<Character> {
>         ...
> }
> 
> The syntax X&Y represents the intersection of two types. The syntax X|Y represents the union of two types.
> 

What does it mean?

> Node<String> node = ... ;
> switch (node)
> case (is Leaf<String>) { 
>     leaf(node.value); 
> }
> case (is Branch<String>) { 
>     branch(node.left, node.right); 
> }
> else {
>     somethingElse(node);
> }

Haha, finally properly scoped switch statement, but it goes java too much. Braces are required?


More information about the Digitalmars-d mailing list