Let’s say I have
WORLD: make object! [
people: make Object! []
cars: make Object! []
factories: make Object! []
create: func[][print "new world"]
]
How can I chain with the create method? something like this doesn’t work.
(make WORLD[])/create
This is the JavaScript I would like to emulate
(new WORLD()).create()
The idiom in this case is
do get in:INreturns the word'ain the object’s context.GETretrieves the value bound to'aword (in that context). Finally as we expected the value returned byGETto be a function, we just call that function usingDO.For your example given, this would therefore look as follows:
As per Hostile Fork’s suggestion in the comments, here is a fully parenthesised version of the last expression, to make function arity explicit: