From 08a8ca6126a31d8c700ec583672a127a2fb0a87c Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Thu, 29 May 2014 21:22:19 +0100 Subject: [PATCH] Updated variables/result.md --- src/variables/result.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/variables/result.md b/src/variables/result.md index 8ffb402..82b950d 100644 --- a/src/variables/result.md +++ b/src/variables/result.md @@ -1,15 +1,15 @@ # Result -The `result` variable is a special variable that serves as an implicit return. This is useful because in most cases, the control flow semantics of the `return` statement are unneeded. `result` is initialized with the default value for a given return type, so the the following code it starts as `0`, before being initialized to `number` +The `result` variable is a special variable that serves as an implicit return variable. This is useful because in most cases, the control flow semantics of the `return` statement are unneeded. `result` is initialized with the default value for a given return type, so the following code starts as `0`, before being initialized to `number`: ``` nimrod -proc expr(number, power: int): int = +proc `**`(number, power: int): int = result = number for i in 1..power: result *= number ``` -A common gotcha is declaring a variable called result and expecting it to have the same semantics. +A possible gotcha is declaring a variable called result and expecting it to have the same semantics. ``` nimrod proc unexpected(): int = @@ -17,4 +17,4 @@ proc unexpected(): int = result += 5 echo unexpected() # Prints 0, not 10 -``` \ No newline at end of file +```