Created
May 26, 2014 06:01
-
-
Save Integralist/b79b7a7706cc150b457c to your computer and use it in GitHub Desktop.
Revisions
-
Integralist created this gist
May 26, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ I saw this in some code written by BBC principle developer @kenoir and later located the following useful post: http://mudge.name/2011/01/26/passing-blocks-in-ruby-without-block.html ```ruby class Foo def initialize bar &Proc.new # voodoo end def bar(&block) block.call end end Foo.new { puts "hai" } ``` In short, the reason it works is this: > If `Proc.new` is called from inside a method without any arguments of its own, it will return a new Proc containing the block given to its surrounding method. Very nice!