Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
class Closures
|
||||
{
|
||||
Void main ()
|
||||
{
|
||||
// define a list of functions, which take no arguments and return an Int
|
||||
|->Int|[] functions := [,]
|
||||
|
||||
// create and store a function which returns i*i for i in 0 to 10
|
||||
(0..10).each |Int i|
|
||||
{
|
||||
functions.add (|->Int| { i*i })
|
||||
}
|
||||
|
||||
// show result of calling function at index position 7
|
||||
echo ("Function at index: " + 7 + " outputs " + functions[7].call)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue