End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
String#each_byte
str.each_byte {|integer| block } → str
str.each_byte → an_enumerator
string.c
View on GitHub ↗
static VALUE
rb_str_each_byte(VALUE str)
{
RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_byte_size);
return rb_str_enumerate_bytes(str, 0);
}
Passes each byte in str to the given block, or returns an enumerator if no block is given.
Example
"hello".each_byte {|c| print c, ' ' }
produces:
104 101 108 108 111