From: "Benjamin J. Tilly" Date: 2001-05-29T10:12:52+09:00 Subject: [ruby-talk:15901] Re: is it possible to dynamically coerce objects types in Ruby? jonas wrote: >> Try 'to_int' which is for that particular purpose, not 'to_i' which is >> for explicit conversion to integer. And when you want something to be >> string, try 'to_str'. > >Why is there a difference between to_i and to_int? Is it the principle >of biggest surprise!? :-) You will not be far wrong if you think of "to_int" as being to_i combined with the assertion that what you are dealing with was supposed to be "integer-like". That is, to_i will endeavour to give you an integer, no matter how poorly the shoe fits, while to_int will give you an integer, but not if it means lopping off a toe or three in the process. If you wish you can think of the missing "nt" in to_i to represent the lopped off toes from trying to make the shoe fit what it didn't... :-) Cheers, Ben