Kirk Haines wrote:
> class Fixnum
>   def to_str
>     self.to_s
>   end
> end

Note: please treat this as for pedagogical purposes only. I'd say it's a 
really bad idea to do this in real code. Firstly, you're changing a core 
class, which may affect other libraries you use which depend on standard 
behaviour. And secondly, making Fixnum auto-convert into a String may 
mask bugs which then won't appear until later on in your program's 
execution, making debugging difficult.

Better to be explicit with the conversions:

    preferred = num.to_i + var1
    puts 'well ' + preferred.to_s + ' is better'

or the more idiomatic use of string interpolation:

   puts "well #{num.to_i + var1} is better"
-- 
Posted via http://www.ruby-forum.com/.