We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b96aa7 commit b28c316Copy full SHA for b28c316
tests/closure/tcapture.nim
@@ -1,6 +1,9 @@
1
discard """
2
output: '''
3
-to be, or not to be'''
+to be, or not to be
4
+(v: 1)
5
6
+'''
7
joinable: false
8
"""
9
@@ -9,4 +12,15 @@ import sequtils, sugar
12
let m = @[proc (s: string): string = "to " & s, proc (s: string): string = "not to " & s]
10
13
var l = m.mapIt(capture([it], proc (s: string): string = it(s)))
11
14
let r = l.mapIt(it("be"))
-echo r[0] & ", or " & r[1]
15
+echo r[0] & ", or " & r[1]
16
+
17
+type O = object
18
+ v: int
19
+var o = O(v: 1)
20
+var execute: proc()
21
+capture [o]:
22
+ execute = proc() =
23
+ echo o
24
+execute()
25
+o.v = -1
26
0 commit comments