{"version":"1.0","url":"https://rubyco.hatenadiary.org/entry/20060311/proc","description":"Proc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u4fdd\u6301\u3057\u307e\u3059\u3002 \u3067\u3059\u304b\u3089\u3001\u5916\u90e8\u3067\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u304c\u66f8\u304d\u63db\u3048\u3089\u308c\u308b\u3068\u3001Proc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4e2d\u3067\u53c2\u7167\u3057\u3066\u3044\u305f\u5909\u6570\u306e\u5024\u3082\u5909\u5316\u3057\u307e\u3059\u3002 n = 123 p = proc { puts n } p.call #=> 123 n = 456 p.call #=> 456 def rubyco(p, n) p.call end rubyco(p, 789) #=> 456\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u3067\u306f\u3001\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u304c\u6bce\u56de\u751f\u6210\u3055\u308c\u307e\u3059\u304b\u3089\u3001\u5225\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u304c\u4fdd\u6301\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 def func(x) n = x return proc { puts n } end x = fun\u2026","type":"rich","image_url":null,"blog_url":"https://rubyco.hatenadiary.org/","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Frubyco.hatenadiary.org%2Fentry%2F20060311%2Fproc\" title=\"Proc\u3068\u5909\u6570 - rubyco\uff08\u308b\u3073\u3053\uff09\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","height":"190","author_name":"rubyco","provider_url":"https://hatena.blog","width":"100%","published":"2006-03-11 00:00:01","blog_title":"rubyco\uff08\u308b\u3073\u3053\uff09\u306e\u65e5\u8a18","categories":[],"author_url":"https://blog.hatena.ne.jp/rubyco/","title":"Proc\u3068\u5909\u6570"}