[DGD] casting nil (another idea...)

Robert Forshaw iouswuoibev at hotmail.com
Tue Mar 23 17:28:43 CET 2004


Just a small idea. How about being able to typecast nil to integer, 
converting it to 0? If a variable is expected to hold nil, 0, or another 
integer, and you want to always treat it as an integer, then:

luck -= (int)query_property("luck_reduction");

Looks much neater than:

int i;
if((i = query_property("luck_reduction") == nil)
    i = 0;
luck -= i;

And probably saves a few ticks as well.

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list