logoalt Hacker News

koolba • today at 12:21 PM • 2 replies • view on HN

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.


Replies

vidarh • today at 1:40 PM

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.

XYen0n • today at 12:46 PM

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.