Skip to content

Instantly share code, notes, and snippets.

@asiniy
Created July 4, 2018 07:10
Show Gist options
  • Save asiniy/758d0587cf936ddfe93f6fa726a11d5d to your computer and use it in GitHub Desktop.
Save asiniy/758d0587cf936ddfe93f6fa726a11d5d to your computer and use it in GitHub Desktop.
Rubyish Hash#Fetch # Extending JavaScript with ease (beginner level tutorial)
o = { a: 'b' }
o.fetch(:a) # => returns 'b'
o.fetch(:nonexistant) # => throws prog.rb:2:in `fetch': key not found (KeyError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment