Skip to content

Adding closure documentation #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/scala/stdlib/HigherOrderFunctions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ object HigherOrderFunctions extends FlatSpec with Matchers with org.scalaexercis
result should be(res0)
}

/** {{{
/** Here the only variable used in the function body, `i * 10`, is `i`, which is defined as a parameter to the function.
*
*{{{
* val multiplier = (i:Int) => i * 10
* }}}
*
* Here the only variable used in the function body, `i * 10`, is `i`, which is defined as a parameter to the function.
* A closure is a function which maintains a reference to one or more variables outside of the function scope (it "closes over" the variables). Scala will detect that you are using variables outside of scope and create an object instance to hold the shared variables.
*/
def meetClosureHigherOrderFunctions(res0: Int, res1: Int) {
var incrementer = 1
Expand Down