[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: How to evaluate file as Ruby code?
From: "Caleb Tennis" <caleb () aei-tech ! com>
Date: 2006-02-22 14:32:35
Message-ID: 37947.192.168.2.159.1140618737.squirrel () www ! aei-tech ! com
[Download RAW message or body]
>> For example, I have a file "foo" which contains the lines
>>
>> abc=4
>> def=5
>>
>> I would like to "evaluate" the file such that after this, the
>> variable abc is set to 4 and def is set to 5.
> load <file> will load and evaluate the file, it will reload and
> re-evaluate.
Keep in mind that using load keeps local variables local to their scope
within the file:
tc@tc8 ~ $ cat foo.txt
a = 5
@b = 10
tc@tc8 ~ $ irb
irb(main):001:0> load 'foo.txt'
=> true
irb(main):002:0> @b
=> 10
irb(main):003:0> a
NameError: undefined local variable or method `a' for #<Object:0xb7d37970
@b=10>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic