Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Nested function
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Uses == === Helper === A nested function typically acts as a [[wrapper function|helper function]] or a [[recursion (computer science)|recursive function]]. === Control flow === Nested functions can be used for unstructured [[control flow]], by using the return statement for general unstructured control flow. This can be used for finer-grained control than is possible with other built-in features of the language β for example, it can allow early termination of a for loop if <code>break</code> is not available, or early termination of a nested [[for loop]] if a multi-level <code>break</code> or exceptions are not available. === Higher-order functions === {{Main|Higher-order function}} In some languages, it is possible to create a nested function that accesses a set of parameters from the outer function, that is a [[Closure (computer programming)|closure]], and have that function be the outer function's return value. Thus it is possible to return a function that is set to fulfill a certain task with little or no further parameters given to it, which can increase performance quite significantly.<ref name="Higher-Order Functions and Lambdas β Kotlin Programming Language">[http://kotlinlang.org/docs/reference/inline-functions.html Higher-Order Functions and Lambdas - Kotlin Programming Language]</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)