method
each_byte
v2_1_10 -
Show latest stable
- Class:
IO
each_byte()public
Calls the given block once for each byte (0..255) in ios, passing the byte as an argument. The stream must be opened for reading or an IOError will be raised.
If no block is given, an enumerator is returned instead.
f = File.new("testfile") checksum = 0 f.each_byte {|x| checksum ^= x } #=> #<File:testfile> checksum #=> 12