Not exactly sure what I'm doing wrong
var
x = (5 + 1) * 6 # ok 36
echo (5 + 1) * 6 # Error: type mismatch: got (void, int)
Also, I find the new "Warning: a [b] will be parsed as command syntax; spacing is deprecated [Deprecated]" slightly confusing.
Can anyone help explain, with an example?
Thanks
the parser is interpreting your code as:
(echo(5 + 1)) * 6
should it?
[python]
print (5 + 1) * 6
36
even 'echo ((5 + 1) * 6 ))' gives the 'spacing is deprecated' warning
(just doesn't feel right to me, though I'm not a language professor)
Oh well... thanks
Yes of course you get the spacing warning, because you have the spacing between the print, and the braces pair. Nim is not python, just because something works in python in a specific way it does not automatically mean that nim needs to behave the same way. But despite that, in the current version of python you get the same error as in Nim:
>>> print (5 + 1) * 6
6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
Ok, thanks for the clarification
I know Nim isn't python, but from a new user's perspective, all (or most of) the 'echo's in the nim manual are shown python-style eg. echo thing, not echo(thing)
It would not be obvious to them (and wasn't to me) that the brackets (or implied brackets) and spacing are important. From the "Warning: a [b] will be parsed as command syntax" it is not exactly intuitive in the case of 'echo' that 'a' is the function and 'b' shown in square brackets is it's argument. (it looks more like array access)
However, despite it's tone, your comment helped me gain that understanding, so thanks