Skip to content

Instantly share code, notes, and snippets.

@tiegz
Created March 16, 2011 18:19
Show Gist options
  • Save tiegz/872994 to your computer and use it in GitHub Desktop.
Save tiegz/872994 to your computer and use it in GitHub Desktop.
# This just demonstrates that "Proc.new" will inherit its containing method's proc argument
# if not given an argument.
n = 100_000
class Foo
def self.return_proc_wout_arg(); Proc.new(); end
end
n.times { (Foo.return_proc_wout_arg {|a| print a }).call('.') }
# An exception occurred running rbx_bug.rb
# tried to create a Proc object without a block (ArgumentError)
#
# Backtrace:
# Proc.new at kernel/common/proc.rb:34
# Foo.return_proc_wout_arg at rbx_bug.rb:4
# { } in main.__script__ at rbx_bug.rb:7
# Integer(Fixnum)#times at kernel/common/integer.rb:121
# main.__script__ at rbx_bug.rb:7
# Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:67
# Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:91
# Rubinius::Loader#script at kernel/loader.rb:583
# Rubinius::Loader#main at kernel/loader.rb:713
# Rubinius::Loader.main at kernel/loader.rb:752
# Object#__script__ at kernel/loader.rb:763
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment