Created
July 17, 2010 15:22
-
-
Save gsinclair/479572 to your computer and use it in GitHub Desktop.
Ruby 1.9.2-rc1: instance_eval can't handle a lambda (needs a proc)
This file contains 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 InstanceEval | |
def initialize(code) | |
@code = code | |
@context = Object.new | |
end | |
def run | |
code = @code | |
result = @context.instance_eval(&code) | |
"* run --> #{result.inspect}" | |
end | |
end | |
p = proc { :p } | |
l = lambda { :l } | |
puts InstanceEval.new(p).run | |
puts InstanceEval.new(l).run | |
# The output in 1.8.7-p72 and in 1.9.1-p378: | |
# | |
# * run --> :p | |
# * run --> :l | |
# | |
# The output in 1.9.2-rc1: | |
# | |
# * run --> :p | |
# code.rb:15:... wrong number of arguments (1 for 0) (ArgumentError) | |
# from code.rb:10:in `instance_eval' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@marick, the reason is not known. Ruby 1.8.7 just does it (see example output above).