Skip to content

Instantly share code, notes, and snippets.

@johnkpaul
Created August 24, 2016 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnkpaul/0779fcd65ba27b6949385fa0c8838862 to your computer and use it in GitHub Desktop.
Save johnkpaul/0779fcd65ba27b6949385fa0c8838862 to your computer and use it in GitHub Desktop.
Why do global methods in the repl end up inside private methods of lambdas?
2.2.1 :001 > def test_method
2.2.1 :002?> puts 'test'
2.2.1 :003?> end
=> :test_method
2.2.1 :004 > l = -> { puts 'lambda' }
=> #<Proc:0x007fc7ca113a20@(irb):4 (lambda)>
2.2.1 :005 > l.private_methods.include? :l
=> false
2.2.1 :006 > l.private_methods.include? :test_method
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment