for i in 0..10: for j in 0..10: echo "hello";
must print hello 100 times, but compiller prints "n.nim(2, 1) Error: complex statement requires indentation"
why?
Because the statement is too complex, try this:
for i in 0..10:
for j in 0..10:
echo "hello"
Or this
for i in 0..10: (for j in 0..10: echo "hello")
Largely opinion based: Limit one liner use to only analogues of C's '?' operator.
So,
let permission_granted = someproc(p1) # ... let foo = if permission_granted != 0: "allowed" else: "denied"
Similarly one might argue C's one statement rule for loops but I'd advise to always properly indent loop constructs.
Reason/reminder: Readability. It is known from many studies that (non) readability is a very major factor in code quality, particularly when considering maintenance. After all Araq has created Nim in a way to allow for (or even provoke) good readability for a reason.
(P.S. Would someone kindly tell me how to get code properly formatted here?)
For inline code put double backticks around your code block. (RST-way)
For code block, put three backticks followed by 'nim', and then paste your code, and then finish with three backticks. (markdown-way)
(Yes, it is complete mess and it should be replaced by markdown-only syntax)
More info about current way of doing things: https://forum.nim-lang.org/about/rst