each_byte block logics : each_byte « String « Ruby






each_byte block logics


#!/usr/bin/env ruby

thoreau = "If a man does not keep pace with his companions, perhaps it is because he hears a different drummer."

thoreau.each_byte do |c|
  print c.chr, "/"
end

 








Related examples in the same category

1.each_byte takes a string apart byte by byte, returning the decimal value for the character at each index location.
2.Convert each decimal to its character equivalent with Integer's chr method
3.Append the output to an array
4.Loop through each byte from a string
5.Use case to deal with special key