Results 1 to 3 of 3

Thread: Lua: Difference between "end" and "end,"

  1. #1

    Default Lua: Difference between "end" and "end,"

    Well - the title says it all: What's the difference between "end" and "end," (with a comma) an Lua programming? I have not been able to find the "end," (with a comma) in any literature about Lua.

    Thanks!

  2. #2
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    'end' ends a code block, for example in if-then constructs, or a function. The comma is a list separator (for lua tables). Thats it.

    So the 'end,' basically means that the codeblock ending (by the 'end' statement) is part of a list (indicated by the comma). The most common use (I can think of) is defining functions in a table.

    Example;
    Code:
    local mylist = {
        var1 = 12,
        var2 = 'some value',
        var3 = function (self)
                   -- do something here
               end,
        var4 = true,
    }
    var3 is a function, but is coded as part of a lua table in 'mylist', so the 'end,' ends the function codeblock and starts the next item in the table 'mylist'.
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  3. #3

    Default

    Thanks - it helps me understanding my Lua challenges!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •