In ruby, why would defined?
return a string? Most other ruby methods ending with a ?
return a boolean.
Was this a hack to support a feature req
No, it was neither a hack nor a misuse of Ruby convention. As matz writes in ruby-talk 7986:
The '?' methods ... return either
- (a) true or false
- (b) non-false informative value or nil
defined?
falls into (b).
Also, as commenters have pointed out, defined?
is not a method. Matz expands in ruby-talk 1637:
[
defined?
is] a control structure. Not everything is a message send in Ruby, e.g. control structures, variables, blocks are not objects.defined?
is among these things.