by irjustin · 3y ago · 0 comments
`.dig(:key, :key, :etc)` is so nice to find deeply nested data without blowing up.
One thing I don't miss is knowing whether a hash's keys are strings vs symbols. While it's easily solvable, I've definitely lost time only to smack myself that I need to use a str but was always feeding a sym and swore that this should be a sym based hash.
try:
value = data["foo"]["bar"]["baz"]
except KeyError:
value = NoneUsing errors as general flow control makes me uncomfortable. It shouldn't be an error or exception except in.... Actual problems.