P
Peña, Botp
Hi All,
I may not be feeling well today, so pardon me pls.
I am modifying/cleaning many scripts here (most of them just a page long,
two at most, and most of them coming fr perl/bash origin).
I encountered a wall though.
Consider,
#sample script---------------->8
foo=["a","b","c"]
def mfoo
foo.each do |f|
p f
end
end
# go-go-go!
mfoo
#end sample script------------>8
i just enclosed the some commands with def mfoo / end to make a new method
mfoo and make my script cleaner, and besides, i may be calling mfoo again.
running the above, i get:
So how can i force foo visible to mfoo()?
Thanks in advance.
-botp
I may not be feeling well today, so pardon me pls.
I am modifying/cleaning many scripts here (most of them just a page long,
two at most, and most of them coming fr perl/bash origin).
I encountered a wall though.
Consider,
cat test.rb
#sample script---------------->8
foo=["a","b","c"]
def mfoo
foo.each do |f|
p f
end
end
# go-go-go!
mfoo
#end sample script------------>8
i just enclosed the some commands with def mfoo / end to make a new method
mfoo and make my script cleaner, and besides, i may be calling mfoo again.
running the above, i get:
test.rb
from test.rb:9test.rb:4:in `mfoo': undefined local variable or method `foo'
So how can i force foo visible to mfoo()?
Thanks in advance.
-botp