On Oct 14, 3:40 pm, "Gerardo Santana Góíez Garrido" <gerardo.sant... / gmail.com> wrote: > zero in Ruby is true, not false, in a boolean context. > > What does false.to_i return? An exception. There is not a numeric > interpretation for false. > > What about nil. nil is nothing. The only other object that evaluates > to false in a boolean context. > > What does nil.to_i return? Zero. And I wonder why. How can nil be > interpreted as a number. It's beyond me. > > Anyone care to explain it to me? In the strictest sense of what's "proper" I suppose you are right, it ought return a NoMethodError. However more often than not it seems to be exactly what we would want to happen anyway. If it were not for that convenience we'd have a bunch of these all over the place: (x ? x.to_i : 0) Following through with this, we also have to_s => "", to_a => [] and to_f => 0.0. And I support adding to_h => {}. T.