From: Dave Thomas Date: 2000-11-27T03:12:11+09:00 Subject: [ruby-talk:6581] Re: booleans Maurice Szmurlo writes: > ruby 3 > a = 10**10000 / 1.5 > ruby 4 > puts a > Infinity ## still OK > ruby 5 > puts a.infinite? > 1 ## oups! why not "true"? > ruby 6 > a = 10.0 > ruby 7 > puts a.infinite? > nil ## oups! why not "false"? > > (the "finite?" predicate returns true and false) It's because infinite? is trying to get extra information back to you: a = 1.0/0 # => Infinity a.infinite? # => 1 a = -1.0/0 # => -Infinity a.infinite? # => -1 > conversely if true and false are to exist (which I agree with at > least for esthetic reasons) why are't they both the only members of > a "Boolean" class and why isn't nil true (only false would represent > false)? I believe a boolean class may be on the way. Nil is false simply because it's convenient: h[key] = 0 unless h[key] or h[hey] ||= 0 or while STDIN.gets and so on. Personally, I'd argue to remove true and false, as their position is far more tenuous, but I can live with them once they're here. Dave