I’m trying to learn from some code created for RubyQuiz, but it seems to be built with an older version of Ruby that is now throwing an error when I try it with 1.9.2. I get this error when running the tests
in `>=': comparison of Fixnum with String failed (ArgumentError)
running the line ‘if c >= ?A and c <= ?Z’. Being rather inexperienced, I’m not sure if that’s something that can be tweaked within the function itself, or if i’d need to post the whole code, which might not make it worthwhile. Please advise
def process(s, &combiner)
s = sanitize(s)
out = ""
s.each_byte { |c|
if c >= ?A and c <= ?Z #error
key = @keystream.get
res = combiner.call(c, key[0])
out << res.chr
else
out << c.chr
end
}
return out
end
?Aused to return the ascii code of the character inRuby 1.8, but return the character itself now inRuby 1.9. You should replace?Aby'A'.ord.In
Ruby 1.8.xIn
Ruby 1.9.xIn both
Ruby 1.8.xand1.9.x