Hacker News new | ask | show | jobs
by koolba 25 days ago
What happens if you pass in (nothing_provided = true) as the value?

Does it return back the empty current value?

I’m no ruby expert, but seems like the freeze approach avoids that with a unique inaccessible object.

2 comments

If you pass in (nothing_provided = true), the method received "true" as its argument, not the expression, so it acts exactly as if you pass in true.
This expression returns true. It should be in a different scope from the default parameter value, so I assume it is equivalent to passing true directly.