And what if the input string correctly contains double quotes?? ;-)
String doesn't have a each_with_index method.
class String
def each_with_index
counter = 0
each_byte do |char|
yield char, counter
counter += 1
end
end
end
"abc".each_with_index do |char, index|
puts char.chr + ' ' + index.to_s
end
Please note that char is an integer, so you have to call char.chr.
Untested, but it should work.
--
Posted via http://www.ruby-forum.com/.