- Home /
Can I use lambda expressions or anonymous methods in JS?
I would like to use lambda expressions or anonymous methods in JS.
- Is it possible?
- If so, how?
Example code illustrating what I would want to achieve:
function Start() { yield WaitWhile( /* What goes here? */ );
// In C# I could have written:
// yield return WaitWhile( () => name == "wait" );
}
function WaitWhile(System.Func.<boolean> predicate) { while (predicate()) yield; }
I know I can make use of named delegates, but that is not what I want to achieve here.
Answer by Eric5h5 · Mar 12, 2011 at 08:32 PM
Yes, see the Mono upgrade page in the docs.
I really wish Unity would have thought through their changes to web structure, so many broken links on this site now.
Your answer
Follow this Question
Related Questions
Script translation 2 Answers
Can I declare properties in JS? 1 Answer
DIFFERENCES between (true)javascript and Unityjavascript - prototyping 2 Answers
How should I decide if I should use C#, JavaScript (UnityScript) or Boo for my project? 14 Answers
What are the Syntax Differences in C# and Javascript? 7 Answers