News for hackers. Stuff that matters.
Re:Hello Ruby – Almost there by ploxiln on Monday August 03, 2015 @02:13PM (#9998454)
If you don't know the type which a name references (or whether it is nil), you have to figure that out before you call any methods on it, in an "external" way. So you have to do " == nil" or "typeof(mything) ==" or "isinstance(mything, type)". This is true for almost every method (except "nil?" in ruby.)

Ruby has a lot of these special cases where there's a gimmicky way to do something which is not the general purpose way and is not the right way to think about that kind of logic. "== nil" is just as short as ".nil?" and isn't as wacky as intentionally calling methods of nil (and every other object needing to have this nil-specific interface).

Re:Hello Ruby – Almost there by skywhopper on Monday August 03, 2015 @03:25PM (#9999119)
This isn't a gimmick or a special case. "nil" is an object of type NilClass, which is a subclass of Object: http://ruby-doc.org/core-2.2.0/NilClass.html

In fact, everything in Ruby is an object. Languages that treat "nil" or "44" as not being instances of a class are the ones making special cases.

Re:Hello Ruby – Almost there by svisser on Monday August 03, 2015 @04:09PM (#9999404)
The absence of an object is not a special case.

To indicate that with a "nill" object is a special case?