Open ih4cku opened 8 years ago
When a function is defined with the dict attribute it can be used like a member function in object oriented programming.
dict
function MyLen() dict return len(self.data) endfunction let mydict = {'data': [0, 1, 2, 3], 'len': function("MyLen")} echo mydict.len()
In the above codes, function("MyLen") is used as a Funcref.
function("MyLen")
Funcref
Also you can directly assign the function to a dictionary.
let mydict = {'data': [0, 1, 2, 3]} function mydict.len() dict return len(self.data) endfunction echo mydict.len()
Dictionary function
When a function is defined with the
dict
attribute it can be used like a member function in object oriented programming.In the above codes,
function("MyLen")
is used as aFuncref
.Also you can directly assign the function to a dictionary.