Skip to content
instance method

String#chr

() -> ::String
chr → string

Returns a string containing the first character of self:

Example
'hello'.chr     # => "h"
'тест'.chr      # => "т"
'こんにちは'.chr # => "こ"
''.chr          # => ""

Related: see Converting to New String.

See also #chop! #clear #chop #codepoints also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0