If you have
nil
where you expect a
Hash
, that's a bug, and the correct response is to fix the bug so you don't get
nil
in the first place, not to work around the
nil
! And if you "find yourself having to do this all the time", then you have a
lot of bugs, and you should tighten up your design, development, testing, code review, and QA processes (and, ultimately, your
hiring processes, so you don't hire programmers that write such silly bugs in the first place)! —
Jörg W Mittag 6 secs ago