lua-users home
lua-l archive

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


On Wed, Jun 26, 2013 at 2:41 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
I suspect this is going to work like 'Learn C++ in 24 hours' ;)

steve d.



Looks nice, though there are a couple things that concerned me:
-- 'or' and 'and' are short-circuited.
-- This is similar to the a?b:c operator in C/js:
ans = aBoolValue and 'yes' or 'no'  --> 'no'

- no mention that this doesn't work when c is nil, a commonly reported "bug" by beginners.

-  no mention that tables do not preserve ordering of non-integer keys. I might also go as far as to mention that tables have some internal mechanism to make them usable as arrays without the speed penalty you'd normally experience using a hash map as an array. (no need to describe what the mechanism is...)
function LoudDog:makeSound()
  s = self.sound .. ' '                       -- 2.
  print(s .. s .. s)
end

seymour = LoudDog:new()                       -- 3.
seymour:makeSound()  -- 'woof woof woof'      -- 4.

-- where'd the trailing space go?


Otherwise it looks quite useful, assuming you know enough about Python and JS to get the references.


--
Sent from my Game Boy.