[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Comparing userdata with other types
- From: Matthias Kluwe <mkluwe@...>
- Date: Fri, 5 Jun 2009 17:21:46 +0200
2009/5/31 Ivo Beltchev <firstname.lastname@example.org>:
> I am embedding Lua in my application and I want to expose some objects to
> the Lua scripts. Different objects have different sets of properties. For
> example object1 can have speed and length and object2 can have mass and
> Currently if the script wants to check if an object has mass>20 it has to
> if (obj.mass and obj.mass>20)...
Personally, I like "cumbersome" code very much. To the reader, it
clearly tells what you want to do (check if the object has a property
"mass" and if it has, compare it).