Settings

Theme

Optimizing Ruby's JSON, Part 2

byroot.github.io

5 points by mscccc a year ago · 2 comments

Reader

jeremy_k a year ago

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

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection