From: matz@... (Yukihiro Matsumoto) Date: 2002-06-25T00:27:03+09:00 Subject: Re: No exceptions from String#to_i Hi, In message "Re: No exceptions from String#to_i" on 02/06/24, Nikodemus Siivola writes: |I find this mildly strange: | | Integer('') #-> exception | | Integer(nil) == 0 | Integer(false) #-> exception | | Integer(:foo) == 14145 | Integer('foo') #-> exception | |Is this 'jus the way it is', or is there a reason? I suppose symbols get |hashed, but then why not apply the same logic to strings as well? Something that isn't naturally convertable to an integer causes error. Symbols and nil are exception from historical reason, but maybe they will be error in the future. |Why ? | | Array(foo) == foo.to_a | String(foo) == foo.to_s | Integer(foo) != foo.to_i | Float(foo) != foo.to_f Functional style methods are more strict than their OO style counterpart in general. matz.