lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, 13 Sep 2006 13:49:44 -0500, Shmuel Zeigerman <shmuz@actcom.co.il> wrote:

Thomas Blom wrote:
If I want the parameter "loop" for a sound to default to true when unspecified I thought I would write:
 shouldLoop = sounds[1].loop or true  -- (nil or true) => true
 but then it doesn't work for the second entry:
 shouldLoop = sounds[2].loop or true  -- (false or true) => true
 This was a bit of a surprise, since (nil or false) => false.
  What's the elegant idiom for this situation?

shouldLoop = sounds[i].loop == nil

Thanks for the responses; this one doesn't quite work: if loop=true, then shouldLoop will be false. (The user should be able to specify loop, even if it defaults to true)

-t



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/