Sha256: 834f3c0ba9e6e5f8512ef51084cd93a8d909a1258fef253b2a8481f32b13a314

Contents?: true

Size: 462 Bytes

Versions: 9

Compression:

Stored size: 462 Bytes

Contents

# closure.fy
# Example of closures in fancy

# method that returns a closure
def create_counter: number {
  closure = {
    number = number + 1
  }
  closure
}

# create a counter from 100 upwards
closure = create_counter: 100
# this will print numbers 100 - 120
20 times: {
  Console println: $ closure call
}

# create a counter from 500 upwards
closure = create_counter: 500
# this will print numbers 500 - 510
10 times: {
  Console println: $ closure call
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fancy-0.8.0 examples/closures.fy
fancy-0.7.0 examples/closures.fy
fancy-0.6.0 examples/closures.fy
fancy-0.5.0 examples/closures.fy
fancy-0.4.0 examples/closures.fy
fancy-0.3.3 examples/closures.fy
fancy-0.3.2 examples/closures.fy
fancy-0.3.1 examples/closures.fy
fancy-0.3.0 examples/closures.fy