Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Easy questions about lua — Gideros Forum

Easy questions about lua

edited July 2014 in General questions
Hi,

I am new in lua language so i want to ask something about it. I guess what it is but just make sure what it is :)

First; {} are this brackets represent the like array object ?

Second; while executing functions in some example codes use functionName{} insteadof functionName({}). Is it same thing or not ?

Third; again i saw in the example codes "#self.name" what is it ? why use # this character ?

And lastly any advise about difference like that from other languages ? i know as3,php,js and now learning lua

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited July 2014 Accepted Answer
    Hello @coderontheroad

    1) Yes {} are called tables in lua, but basically they are arrays.
    Making indexed array
    local t = {"value1", "value2", "value3"}
    or associative array
    local t = {key1 = "value1", key2 = "value2", key3 = "value3"}
    2) Exactly as you said, it is for passing table directly function{} is the same as function({})

    3) symbol # takes the number of elements in indexed array
    local t = {"value1", "value2", "value3"}
    print(t) --prints 3
     
    local t = {key1 = "value1", key2 = "value2", key3 = "value3"}
    print(t) --prints 0
    4) Lua is pretty much the same as JavaScript (at least closest from what you have mentioned)

    Having objects and anonymous functions, and json is like tables

    I've been switching a lot between these two languages recently

    Only OOP in Gideros is much prettier than what JavaScript has :)
  • @ar2rsawseen thank you very much :) i am more comfortable now...
Sign In or Register to comment.