D
Dan Fitzpatrick
The following was derived from a portion of the destrutive! operations
thread.
Here is a proposal for evaluating "", 0, and nil in an if statement:
Add empty? to NilClass and Fixnum
class NilClass
def empty?
true
end
end
class Fixnum
def empty?
self == 0 ? true : false
end
end
nil.empty? => true
0.empty? => true
These already exist:
"".empty? => true
[].empty? => true
{}.empty? => true
Dan
thread.
Here is a proposal for evaluating "", 0, and nil in an if statement:
Add empty? to NilClass and Fixnum
class NilClass
def empty?
true
end
end
class Fixnum
def empty?
self == 0 ? true : false
end
end
nil.empty? => true
0.empty? => true
These already exist:
"".empty? => true
[].empty? => true
{}.empty? => true
Dan