Re: simple loops and recursion

From: ishamid [mailto:[email protected]]

puts "Sorry, expected #{expected_value} but got #{actual_value}"

The output does not distinguish number from numeral. Is this standard
or is there something else going on?

The string representation (the output of the to_s method) for strings
and numbers is identical in this case. You might want to use the output
of the ‘inspect’ method instead, as this occasionally returns values
that are more in-line with what you want.

puts “Sorry, expected #{expected_value.inspect} but got

Sorry, expected “98” but got 98

[ 1, ‘1’, 1.275392, ‘1.275392’, nil, /woot/ ].each do |obj|
puts “#{obj.to_s} vs #{obj.inspect}”

#=> 1 vs 1
#=> 1 vs “1”
#=> 1.275392 vs 1.275392
#=> 1.275392 vs “1.275392”
#=> vs nil
#=> (?-mix:woot) vs /woot/