I
Intransition
Messing with optional argument check for the umpteenth time, eg.
def meth(a=Exception)
if a != Exception
...
else
...
end
end
Other's might do:
def meth(*a)
if !a.empty?
a = a.first
...
else
...
end
end
Neither of which are very satisfying. So it occurs to me tonight that
we already have #has_block? to see if a block was passed. So how about
a #has_arguments? to query if _any_ arguments have been passed. So
then...
def meth(a=default)
if has_arguments?
...
else
...
end
end
Ah... now that would be nice.
def meth(a=Exception)
if a != Exception
...
else
...
end
end
Other's might do:
def meth(*a)
if !a.empty?
a = a.first
...
else
...
end
end
Neither of which are very satisfying. So it occurs to me tonight that
we already have #has_block? to see if a block was passed. So how about
a #has_arguments? to query if _any_ arguments have been passed. So
then...
def meth(a=default)
if has_arguments?
...
else
...
end
end
Ah... now that would be nice.