[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Testing global variables for existence?

Hadmut Danisch

12/16/2004 5:38:00 PM

Hi,

I need to set a global variable (e.g. $configfile ) to a default value
if it has not been set before to anything else. In order to
not overwrite it I have to check whether it has been set previously.

$configfile.nil? would do the job, but ruby -w spits out a warning
that the variable has not yet been initialized.

How do I test whether the variable has been set without causing
ruby -w to print a warning in case it has not been set?

regards
Hadmut
3 Answers

ts

12/16/2004 5:46:00 PM

0

>>>>> "H" == Hadmut Danisch <x4@danisch.de> writes:

H> How do I test whether the variable has been set without causing
H> ruby -w to print a warning in case it has not been set?

With defined?

uln% ruby -we '$a = 12 unless defined?($a); p $a'
12
uln%



Guy Decoux


Hadmut Danisch

12/16/2004 5:51:00 PM

0

ts wrote:
>
> With defined?
>
> uln% ruby -we '$a = 12 unless defined?($a); p $a'
> 12
> uln%


Thanks! :-)

Hadmut

Ashikaga

5/9/2007 7:33:00 AM

0

On 20khz Pibbur shrieked:
> skrev Ashikaga:
>> On 13khz Pibbur shrieked:
>>> I'm playing Wow, and I'm currently in Silithus, a place dominated by
>>> insects and insect-like creatures. There are several hives here. one of
>>> them is called Hive Ashi. Plenty of bugs here.
>>
>> I don't know. It's not created by me. I've noticed there are people (or
>> just one person?) who use my name as their usernames in various places,
>> which forced me to choose a different name....
>
> I think you should patent it. Intellectual property. Both Ashi, and iAshi.
> And sue those who infringe. Or ask Polychromic to take care of them.

I would love to, and I certainly believe I am /the/ Ashikaga..., except for
the fact it's a prominent name of a real Japanese family. LOL. I probably
has done more disgrace for the name that I have no lineage of, and I shall
be grateful I am not sued for it. LOL.

iAshi..., well, that's a different story, but if we are strict about it,
it's an invention of Poly, so he probably has more right than I to that
name. LOL.

--
Ashikaga - a29 5/9/2007 12:27:03 AM