Skip to content

Instantly share code, notes, and snippets.

@atton
Created August 25, 2012 13:50
Show Gist options
  • Save atton/3466002 to your computer and use it in GitHub Desktop.
Save atton/3466002 to your computer and use it in GitHub Desktop.
メソッドへの {} 渡し
# -*- coding: utf-8 -*-
# method { ... } だと
# ブロックを渡してるのかハッシュを渡してるのか、ってなるので
# ハッシュを渡したい時は {} を省略して良いらしい
def puts_hash_hoge hash
puts hash[:hoge]
end
puts_hash_hoge :hoge => "hogehoge" , :fuga => "fugafuga"
# puts_hash_hoge {:hoge => "hogehoge" , :fuga => "fugafuga" }
# だと怒られる
@hanachin
Copy link

これはOK

puts_hash_hoge ({:hoge => "hogehoge" , :fuga => "fugafuga"})
puts_hash_hoge({:hoge => "hogehoge" , :fuga => "fugafuga"})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment