1import ceylon.language { parseInteger } 2 3doc "A top-level function, 4 with multi-line documentation." 5void topLevel(String? a, Integer b=5, String* seqs) { 6 function nested(String s) { 7 print(s[1..2]); 8 return true; 9 } 10 for (s in seqs.filter((String x) => x.size > 2)) { 11 nested(s); 12 } 13 value uppers = seqs.map((String x) { 14 return x.uppercased; 15 }); 16 String|Null z = a; 17 {Integer+} ints = { 1, 2, 3, 4, 5 }; 18 value numbers = [ 1, #ffff, #ffff_ffff, $10101010, $1010_1010_1010_1010, 19 123_456_789 ]; 20 value chars = ['a', '\{#ffff}' ]; 21} 22 23shared class Example_1<Element>(name, element) satisfies Comparable<Example_1<Element>> 24 given Element satisfies Comparable<Element> { 25 shared String name; 26 shared Element element; 27 shared [Integer,String] tuple = [1, "2"]; 28 shared late String lastName; 29 variable Integer cnt = 0; 30 31 shared Integer count => cnt; 32 assign count { 33 assert(count >= cnt); 34 cnt = count; 35 } 36 37 shared actual Comparison compare(Example_1<Element> other) { 38 return element <=> other.element; 39 } 40 41 shared actual String string { 42 return "Example with ``element.string``"; 43 } 44} 45 46Example_1<Integer> instance = Example_1 { 47 element = 5; 48 name = "Named args call \{#0060}"; 49}; 50 51object example1 extends Example_1<Integer>("object", 5) { 52}