Skip to content

Instantly share code, notes, and snippets.

@richardkmichael
Created May 1, 2011 10:11
Show Gist options
  • Save richardkmichael/950389 to your computer and use it in GitHub Desktop.
Save richardkmichael/950389 to your computer and use it in GitHub Desktop.
Loading local variables into an IRB session: matz vs. rbx
$ cat foo.rb
s = 'foo'
ruby-1.9.2-p180 :008 > eval File.read('foo.rb')
=> "foo"
ruby-1.9.2-p180 :009 > s
NameError: undefined local variable or method `s' for main:Object
from (irb):9
from /Users/rmichael/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
rbx-1.2.3-20110315 :002 > eval File.read('foo.rb')
=> "foo"
rbx-1.2.3-20110315 :003 > s
=> "foo"
@franckverrot
Copy link

AFAICT, Matz answered here about this. This one of the reason why in a recent project (you know which one :)) I replaced the eval's by simple YAML.load's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment