Would

kindergarden ||= 0

do what you're looking for?

> -----Original Message-----
> From: Dominik Werder [mailto:dwerder / gmx.net]
> Sent: 16 June 2003 12:42
> To: ruby-talk / ruby-lang.org
> Subject: update Var if Var==nil
> 
> 
> Hi there,
> 
> I'm doing often things like:
> 
> kindergarden=0 if kindergarden<0
> 
> Is there any super cool syntax magic to do something like:
> 
> kindergarden=0 if its<0	# <-- no need to repeat the var name?
> 
> 
> It would be cool especially with long var names, or on arrays 
> with long 
> indices!
> 
> 
> bye!
> Dominik
> 
> 


***************************************************************************
This communication (including any attachments) contains confidential information.  If you are not the intended recipient and you have received this communication in error, you should destroy it without copying, disclosing or otherwise using its contents.  Please notify the sender immediately of the error.

Internet communications are not necessarily secure and may be intercepted or changed after they are sent.  Abbey National Treasury Services plc does not accept liability for any loss you may suffer as a result of interception or any liability for such changes.  If you wish to confirm the origin or content of this communication, please contact the sender by using an alternative means of communication.

This communication does not create or modify any contract and, unless otherwise stated, is not intended to be contractually binding.

Abbey National Treasury Services plc. Registered Office:  Abbey National House, 2 Triton Square, Regents Place, London NW1 3AN.  Registered in England under Company Registration Number: 2338548.  Regulated by the Financial Services Authority (FSA).
***************************************************************************