|
|
|
|
|
by cardanome
1273 days ago
|
|
Nim has the same result variable[1] and I absolutely love it. It helps avoid the classic "oh, I forgot to return it" bug. Also makes the code more succinct and saves you from having to type an extra line for explicit return. I kind of get why you would be wary of it, as it is a special variable but compared to other messed up stuff like for example Rust treating a line without semicolon as implicit return, it is a relatively tame solution for this problem and can be easily figured out. Did you ever had any actual bugs caused by the use of result? [1] https://nim-by-example.github.io/variables/result/ |
|
In some cases an implicitly declared variable feels neat and convenient, but I'm not sure it's worth it.