J
James Dinkel
Here is my ruby version:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
Here is the block I wrote (this is actually a little test block for
testing part of a larger block):
------------
def myblock
testvar = ['cool', ' array']
yield testvar
print testvar
end
------------
Now here is a snippet of code that isn't giving the result I would
expect:
------------
myblock do |stuff|
stuff = 'dumb string'
end
------------
This outputs "cool array" when I would expect it to output "dumb string"
since I changed the variable when executing the block. So my question
is: how can I get 'testvar' to change to whatever the end result of
'stuff' is when the block executes?
Thanks,
James Dinkel
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
Here is the block I wrote (this is actually a little test block for
testing part of a larger block):
------------
def myblock
testvar = ['cool', ' array']
yield testvar
print testvar
end
------------
Now here is a snippet of code that isn't giving the result I would
expect:
------------
myblock do |stuff|
stuff = 'dumb string'
end
------------
This outputs "cool array" when I would expect it to output "dumb string"
since I changed the variable when executing the block. So my question
is: how can I get 'testvar' to change to whatever the end result of
'stuff' is when the block executes?
Thanks,
James Dinkel