summary refs log tree commit diff stats
path: root/tests/niminaction/Chapter2/resultaccept.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/niminaction/Chapter2/resultaccept.nim')
-rw-r--r--tests/niminaction/Chapter2/resultaccept.nim28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/niminaction/Chapter2/resultaccept.nim b/tests/niminaction/Chapter2/resultaccept.nim
new file mode 100644
index 000000000..390f7b329
--- /dev/null
+++ b/tests/niminaction/Chapter2/resultaccept.nim
@@ -0,0 +1,28 @@
+discard """
+  output: ""
+"""
+
+# Page 35.
+
+proc implicit: string =
+  "I will be returned"
+  
+proc discarded: string =
+  discard "I will not be returned"
+  
+proc explicit: string =
+  return "I will be returned"
+
+proc resultVar: string =
+  result = "I will be returned"
+  
+proc resultVar2: string =
+  result = ""
+  result.add("I will be ")
+  result.add("returned")
+
+doAssert implicit() == "I will be returned"
+doAssert discarded().len == 0
+doAssert explicit() == "I will be returned"
+doAssert resultVar() == "I will be returned"
+doAssert resultVar2() == "I will be returned"
\ No newline at end of file
ible-island.net> 1997-01-29 21:25:58 -0500 snapshot of project "lynx", label v2_6fm_970129' href='/ingrix/lynx-snapshots/commit/lynx_help/keystroke_commands/cookie_help.html?id=c3ec4181d988501e4d7116f32c669d5ca69e7060'>c3ec4181 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48