iterate over all the characters using a block : char range « String « Ruby






iterate over all the characters using a block


thoreau = "asdfasdfasdf"


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

 








Related examples in the same category

1.Retrieve part of a string with the [] method, using a range.
2.starting at the end of the string using negative numbers, get the second to last character through the eighth to last
3.Range indexes are negative