def func
puts i
end
i = 5
func
In PHP, for example, I could use the "global" keyword in the function.
--
Posted via http://www.ruby-forum.com/.
You want to use a global variable, like so:
def func
puts $i
end
$i = 5
func
The "$" tells Ruby it's global.
> In PHP, for example, I could use the "global" keyword in the function.
Yeah... one of the most distracting "features" of PHP *shrugs*.
Sebastian
--
It was mentioned on CNN that the new prime number discovered recently is
four times bigger than the previous record.
~ John Blasik
def func
puts $i
end
$i = 5
func
--
Posted via http://www.ruby-forum.com/.