Skip to content

Instantly share code, notes, and snippets.

@iamvery
Created September 16, 2014 12:24
Show Gist options
  • Save iamvery/be41aa6ff78a154fc690 to your computer and use it in GitHub Desktop.
Save iamvery/be41aa6ff78a154fc690 to your computer and use it in GitHub Desktop.
params = { some: :thing }
oops = {}
def kwargs(some:)
puts some
end
def hash(args)
puts args.fetch(:some)
end
kwargs(params)
hash(params)
begin
kwargs(oops)
rescue Exception => e
puts e
end
begin
hash(oops)
rescue Exception => e
puts e
end
● master ~/Code/OSS » ruby kwargs-v-hash.rb
thing
thing
missing keyword: some
key not found: :some
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment