I’m just seeing if it possible to make lambdas[1] in makecode arcade?
Like inputs with blocks in it that you can use to execute code inputs with inputs?
Anonymous function - Wikipedia ↩︎
I’m just seeing if it possible to make lambdas[1] in makecode arcade?
Like inputs with blocks in it that you can use to execute code inputs with inputs?
Anonymous function - Wikipedia ↩︎
Lambda syntax is perfectly valid in JavaScript / TypeScript. Blocks also can accept anonymous functions, but the anonymous functions cannot return values.
See the event handler example at the bottom of the Types of Blocks examples in the MakeCode Blocks Playground:
Also refer to the Callbacks with Parameters section of the official documentation:
how about variables for return values?
@Cybercube you can store things in variables for return values but since all variables in blocks are global it can get pretty tricky. very easy to accidentally overwrite your return value when something gets called recursively.
there is exactly one block that takes lamdas with a return value and it’s pause until, but it’s built-in to makecode (there’s no way to replicate its behavior in an extension).
the closest thing you can do is define blocks that take an anonymous function as alex mentioned. you could always make your own return block i guess, something like this:
but it’s pretty gross