Skip to content

lua++ or luapp introduces classes and ports kotlins collections framework to lua

License

Notifications You must be signed in to change notification settings

jkeresman01/luapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lua++

We bring classes and port kotlins collection framework to lua, also 0 based indexing

Still simple, but better and easier to write

Lua Work In Progress

Code writen in lua++

class Person
    local _name ( get, set )
    local _age  ( get, local set )

    Person(name, age)
        self._name = name
        self._age = age
    end

    local function is_minor()
        return self._age < 18
    end

    function description()
        if is_minor() then
            return "I am a minor"
        else
            return "I am an adult"
        end
    end

end

Same code written in pure lua (we transpile to this)

local Person = {}
Person.__index = Person

function Person:new(name, age)
    local self = setmetatable({}, Person)
    self._name = name
    self._age = age
    return self
end

function Person:get_name() return self._name end
function Person:set_name(v) self._name = v end
function Person:get_age()  return self._age end

local function Person_set_age(self, v)
    self._age = v
end

function Person:is_minor()
    return self._age < 18
end

function Person:description()
    if self:is_minor() then
        return "I am a minor"
    else
        return "I am an adult"
    end
end

return Person

About

lua++ or luapp introduces classes and ports kotlins collections framework to lua

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages