From: Sebastian Steinlechner Date: 2006-01-29T06:56:42+09:00 Subject: Re: Accessing global variable from a function --------------enig211ED926D3528FDDFC47BC1B Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Vitaly Belman wrote: > I'd like to access a global variable from within a function, without > passing it as paramater. How do I do it? e.g 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 --------------enig211ED926D3528FDDFC47BC1B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFD2+iK8X9UC2T3lakRApbyAJ9FzNIQ4g0wHiGeHwG7DnLCtGL9yQCfUsGq zTgoouW0ar8zHOt13LxUspU= =Vl1C -----END PGP SIGNATURE----- --------------enig211ED926D3528FDDFC47BC1B--