このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 2.6.0 リファレンスマニュアル

instance method String#each_byte

each_byte {|byte| ... } -> self[permalink][rdoc]
each_byte -> Enumerator

文字列の各バイトに対して繰り返します。

"str".each_byte do |byte|
  p byte
end
    # => 115
    # => 116
    # => 114

"".each_byte do |byte|
  p byte
end
    # => 227
    # => 129
    # => 130

[SEE_ALSO] String#bytes