Char is the class for character literals. It can represent any Unicode codepoint.

Methods

clone()

Get a copy of the character.

IO.println('木'.clone()) #> 木

hash

Return a hash for the character value.

def c = '木'
IO.println(c.hash) #> 7520348167691861062

to_i

Transform the character value into an Int. Return the codepoint value.

def c = '木'
IO.println(c.to_i) #> 26408

to_s

Transform the character value into a String.

def c = '木'
IO.println(c.to_s) #> 木

Operators

<(other), <=(other), >(other), >=(other) operators

Compares this and other characters based on the codepoint value.

def c = 'h'
IO.println('a' <= c && c <= 'z') #> true
IO.println('x' < 'X') #> false
IO.println('森' >= '木') #> true