Mega Code Archive

 
Categories / Ruby / String
 

Sequentially iterate characters as character strings

s = "A\nB"                       # Three ASCII characters on two lines # Works in Ruby 1.9, or in 1.8 with the jcode library: s.each_char { |c| print c, " " } # Prints "A \n B "