Skip to content
instance method

String#chars

() -> ::Array[::String]
() { (::String char) -> void } -> self
chars → array_of_characters

Returns an array of the characters in self:

Example
'hello'.chars     # => ["h", "e", "l", "l", "o"]
'Привет'.chars    # => ["П", "р", "и", "в", "е", "т"]
'こんにちは'.chars # => ["こ", "ん", "に", "ち", "は"]
''.chars          # => []

Related: see Converting to Non-String.

See also #center #chomp #casecmp? #chomp! also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0