Nim/tests/closure/tcapture.nim
Judd 56cf3403b4 introduce capture macro (#12712)
capture works for more cases than `closureScope`.
2019-12-10 13:16:37 +01:00

12 lines
No EOL
303 B
Nim

discard """
output: '''
to be, or not to be'''
joinable: false
"""
import sequtils, sugar
let m = @[proc (s: string): string = "to " & s, proc (s: string): string = "not to " & s]
var l = m.mapIt(capture([it], proc (s: string): string = it(s)))
let r = l.mapIt(it("be"))
echo r[0] & ", or " & r[1]