Id wnat to call a table:func() function with a string. If I write test["func"]() I call test.func and not test:func().Has anybody a idea?
Call self function with string
Started by Wilma456, Feb 06 2017 04:53 PM
2 replies to this topic
#1
Posted 06 February 2017 - 04:53 PM
#2
Posted 06 February 2017 - 06:35 PM
I'm not entirely sure if I'm answering our question correctly but I'll have a go as this thread seems quiet.
tab.func(self) --# we defined self ourselves end --# is same as tab:func() --# self is implied as the first argument by the colon end --# calling these functions can be done like so --# these work for both ways of defining the function above tab.func(tab) --# pass tab manually tab:func() --# again implied first argument as tab via colon --# the one you seem to be interested in but working (or should be) tab["func"](tab)
Edited by Lupus590, 06 February 2017 - 06:35 PM.
#3
Posted 07 February 2017 - 02:45 AM
You need to provide the table as the self argument manually.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











