Page 2 of 2

Re: A good OO lib

Posted: Sun Apr 01, 2012 8:36 pm
by rokit boy
Robin wrote:
rokit boy wrote:What is __len__?
The # operator. It is not overridable for tables in Lua 5.1 (though it will be for Lua 5.2).
rokit boy wrote:Btw. I smell python. Is it python inspired?
Yes.
Do you mean:

Code: Select all

#Food
???
It is possible with tables:

Code: Select all

t = {1,2,3}
a = #t
print (a)
3

Re: A good OO lib

Posted: Sun Apr 01, 2012 9:03 pm
by nevon
rokit boy wrote:Do you mean:

Code: Select all

#Food
???
It is possible with tables:

Code: Select all

t = {1,2,3}
a = #t
print (a)
3
Why don't you just try it and find out...?

Re: A good OO lib

Posted: Mon Apr 02, 2012 12:41 am
by tentus
nevon wrote: Why don't you just try it and find out...?
Image

Re: A good OO lib

Posted: Mon Apr 02, 2012 11:47 am
by rokit boy
tentus wrote:
nevon wrote: Why don't you just try it and find out...?
Image
OT much...

Re: A good OO lib

Posted: Mon Apr 02, 2012 2:32 pm
by Robin
rokit boy wrote:Do you mean:
Yes.
rokit boy wrote:It is possible with tables:
That's not what I meant: you can't change the meaning of the # operator for tables. That changes in Lua 5.2, where #foo looks at the metatable, even if foo is a table.

Re: A good OO lib

Posted: Mon Apr 02, 2012 5:44 pm
by tentus
rokit boy wrote: OT much...
Maybe this will be clearer:
nevon wrote: Why don't you just try it and find out...?
Image