Using Character
The complete source of builtInTypes_character.ek9, compiled by the EK9 compiler. Shown on builtInTypes.html.
#!ek9 defines module site.builtintypes.character defines program CharacterUse() stdout <- Stdout() //Some examples of using Character, some with type inference c1 <- Character() c2 <- 's' c3 as Character := 'é' //Comparisons lessThan <- c1 < c2 lessOrEqual <- c1 <= c2 greaterThan <- c1 > c2 greaterOrEqual <- c1 >= c2 equal <- c1 == c2 notEqual <- c1 != c2 alsoNotEqual <- c1 <> c2 //Other operators length1 <- length c1 //results in not set length2 <- length c2 //results in 1 length3 <- length c3 //results in 1 length4 <- c3.length() //same result (1) - but written in object form hashCode1 <- #? c3 //results in 233 (hashcode method) hashCode2 <- c3.#?() //same result (233) - but written in object form //Promotion to String str1 as String := #^c2 //results String of "s" str2 <- #^c2 //also results String of "s" - uses type inference str3 <- c2.#^() //also results String of "s" - uses type inference and object form //Standard methods upper <- c2.upperCase() //results in 'S' lower <- c2.upperCase().lowerCase() //results in 's' stdout.println(`${lessThan?} ${lessOrEqual?} ${greaterThan?} ${greaterOrEqual?} ${equal?} ${notEqual?} ${alsoNotEqual?}`) stdout.println(`${length1?} ${length2} ${length3} ${length4} ${hashCode1} ${hashCode2}`) stdout.println(`${str1} ${str2} ${str3} ${upper} ${lower}`)
Download builtInTypes_character.ek9
Output
false false false false false false false false 1 1 1 233 233 s s s S s