ERights Home elang / scalars 
Back to: boolean Type No Next Sibling

Scalar Type:

E's chars are standard 16-bit unicode characters. Character literals are written just as in Java, a single quote, a character specifier (***what's the name for this***) and a closing single quote. The character specifier can be a single non-special character, or a backslash followed by an escape sequence.

? pragma.syntax("0.8")

? 'a'.asInteger()
# value: 97

? '\n'.asInteger()
# value: 10

Here are the char operators in precedence order:

Boolean Comparisons (non-associative)

Example Meaning Expansion Value
'a' == 'c' Are they the same? __equalizer.sameEver('a', 'c') false
'a' != 'c' Are they different? __equalizer.sameEver('a', 'c').not() true

As you'd expect.

Magnitude Comparisons (non-associative)

Example Meaning Expansion Value
'a' < 'c'
less than
'a' compareTo('c') belowZero
'a' <= 'c'
less or equal to
'a' compareTo('c') atMostZero
'a' >= 'c'
greater or equal to
'a' compareTo('c') atLeastZero
'a' > 'c'
greater than
'a' compareTo('c') aboveZero

If you ask the chars to compare themselves, they compare according to their unicode character codes. For locale-specific sorting orders, see ***.

Additive Expressions (left associative)

Example Meaning Expansion Value
'a' + 2 addition 'a' add(2) 'c'
'a' - 'c' subtraction 'a' subtract('c') -2

You can add a char and an integer to get a new char whose character code differs by that amount. You can subtract two chars to get the distance between their character codes.

Additional char Messages

In addition to the messages corresponding to the above operators, chars respond to the following messages.

? 'a'.asInteger()
# value: 97

For additional messages, see the javadoc-umentation for java.lang.Character. Many of the static methods found there will be turned into instance methods on chars, but this hasn't happened yet.


Unless stated otherwise, all text on this page which is either unattributed or by Mark S. Miller is hereby placed in the public domain.
ERights Home elang / scalars 
Back to: boolean Type No Next Sibling
Download    FAQ    API    Mail Archive    Donate

report bug (including invalid html)

Golden Key Campaign Blue Ribbon Campaign