Nikolai Weibull [2011-10-14 18:11]:
> Here°«s a more general solution that allows you to set d to a
> value independent of the desired default value for the argument:
>
> def m(a = (d = true; nil))
>    # d will be true if argument a wasn°«t specified
> end
exactly! but i hardly ever have a use case for this. i usually don't
care about the value of 'a' when i'm in the default case.

it reminds me of another useful technique, though:

   seen = Hash.new { |h, k| h[k] = true; false }
   [1, 2, 3, 2, 3, 4].each { |i| p i unless seen[i] }

contrived example, i know. but comes in handy at times.

> One easily forgets how expressive Ruby can be. Or how easily it
>is to abuse it.
so true ;)