{"blog_title":"ruby trunk changes","version":"1.0","url":"https://ruby-trunk-changes.hatenablog.com/entry/20111105/proc_call_versus_yield","provider_url":"https://hatena.blog","image_url":null,"height":"190","blog_url":"https://ruby-trunk-changes.hatenablog.com/","width":"100%","categories":["ruby"],"title":"Proc#call vs. yield","author_url":"https://blog.hatena.ne.jp/nagachika/","provider_name":"Hatena Blog","type":"rich","published":"2011-11-05 00:00:01","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fruby-trunk-changes.hatenablog.com%2Fentry%2F20111105%2Fproc_call_versus_yield\" title=\"Proc#call vs. yield - ruby trunk changes\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","description":"\u3054\u5b58\u77e5\u306e\u901a\u308a Ruby \u3067\u306f\u4eee\u5f15\u6570\u306e\u6700\u5f8c\u306b '&' \u3092\u524d\u7f6e\u3057\u305f\u300c\u30d6\u30ed\u30c3\u30af\u5f15\u6570\u300d\u3092\u5ba3\u8a00\u3059\u308b\u3053\u3068\u3067\u3001\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3055\u308c\u308b\u30d6\u30ed\u30c3\u30af\u3092Proc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u53d7\u3051\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3064\u307e\u308a\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3055\u308c\u305f\u30d6\u30ed\u30c3\u30af\u3092\u547c\u3076\u65b9\u6cd5\u306b\u306f2\u901a\u308a\u3042\u308a\u307e\u3059\u3002 def m1 yield :m1 end def m2(&block) block.call(:m2) end m1{|a| p a } # => :m1 m2{|a| p a } # => :m2 \u3053\u306e2\u901a\u308a\u306e\u30d6\u30ed\u30c3\u30af\u547c\u3073\u51fa\u3057\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u89e6\u308c\u305f\u8a18\u4e8b\u3082\u3044\u304f\u3089\u304b\u3042\u308a\u307e\u3059\u3002*1 *2 \u4e3b\u306b\u30d6\u30ed\u30c3\u30af\u304c\u6e21\u3055\u308c\u3066\u3044\u306a\u3044\u6642\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u9055\u3046\u306a\u3069\u306e\u6319\u52d5\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u2026","author_name":"nagachika"}