Hacker News new | ask | show | jobs
Optimizing Ruby's JSON, Part 2 (byroot.github.io)
5 points by mscccc 546 days ago
1 comments

Well I learned something new that default arguments in Ruby can be expressions.

def dump(obj, anIO = (no_args_set = true; nil), limit = nil, kwargs = nil)

I love that trick because it exploits the fact that, like pretty much everything in Ruby, arguments’ default values are expressions. This trick is most commonly used when you need to know if an argument was passed as nil or just not passed

Pretty cool way to do nil checking