Agreed, instance_eval is definitely disgusting, but this trick scores well on readability, it's no more of a trap than some other Ruby idioms, and it serves a good purpose (robustness!).
def foo(bar, baz=(default = true; 'default'))
# it still looks separated from other arguments
if default
puts "#{bar}.times { puts #{baz} }"
else
bar.times { puts baz }
end
end
To anyone who knows more Ruby than I - is there a good reason against that I'm missing?