DEV Community

Discussion on: Using `Hash#fetch` in Ruby for better nil handling

Collapse
 
nashby profile image
Vasiliy Ermolovich

I think it's worth mentioning that Hash#[] is a bit faster than Hash#fetch so if you only want default value behavior it makes sense to use hash[:foo] || :bar in some heavy load cases (more info is here)