Created
October 20, 2014 04:07
-
-
Save thejonanshow/2d40eae1f6d65ef7bf6b to your computer and use it in GitHub Desktop.
Why does :explodes raise LocalJumpError: no block given (yield)?
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 characters
class Dynamical | |
define_method :works_fine do |&block| | |
5.times { |n| block.call(n) } | |
end | |
def also_works_fine(&block) | |
5.times { |n| block.call(n) } | |
end | |
define_method :explodes do |&block| | |
5.times { |n| yield n } | |
end | |
def seems_like_it_should_explode | |
5.times { |n| yield n } | |
end | |
end | |
d = Dynamical.new | |
d.works_fine {|x| puts x} | |
d.also_works_fine {|x| puts x} | |
d.seems_like_it_should_explode {|x| puts x} | |
d.explodes {|x| puts x} |
Author
thejonanshow
commented
Oct 20, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment