Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Integer#chr

int.chr([encoding]) → string

Returns a string containing the character represented by the int‘s value according to encoding.

Example
65.chr    #=> "A"
230.chr   #=> "\xE6"
255.chr(Encoding::UTF_8)   #=> "\u00FF"
See also #ceil #coerce #bit_length #denominator also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1