each_line and each_byte : each_line « String « Ruby






each_line and each_byte


s = "A\nB"                       # Three ASCII characters on two lines
s.each_byte {|b| print b, " " }  # Prints "65 10 66 "
s.each_line {|l| print l.chomp}  # Prints "AB"

 

Related examples in the same category