Yesterday I have seen a code written in Lua using oop method under "Love Framework" so I tried to write the same code by changing some variable to understand it better.
Class = require 'lib/class'-- I'm using Class library https://github.com/vrld/hump/blob/master/class.lua
Bala = Class{__includes = Shubham}
-- here I'm Calling Bala Class
chawal = Bala {
market = "A-Market",
Rashan = "poha"
}
-- Here I've initialized Bala Class using 'init' to pass a argument inside it.
function Bala:init(def)
Shubham.init(self, def)
end
-- Here I've created Shubham class and pass the same argument.
Shubham = Class{}
function Shubham:init(def)
self.market = def.market
self.Rashan = def.Rashan
end
print(chawal.market)
The output is table: 00800320
So my question is how to call those argument from Shubham Class by print() and using terminal only and my 2nd question is why are we using 'self' in Shubham.init(self, def) what's the actual meaning of this line.