Total Nim beginner here. I'm just reading through the Nim basics tutorial and have a super quick question:
What does the @ symbol do?
for example:
a = @[5,6,7,8,9]
echo a[1]
versus without the @ symbol:
a = [5,6,7,8,9]
echo a[1]
Both seem to work and produce the same output.
However, here's another example:
e1: seq[int] = @[]
e1.add(5)
echo e1
In this case, it only works with the @ symbol and fails to compile without it.
What's going on here?
From the arrays chapter:
Arrays are also of a constant size, meaning that the amount of elements (or rather: the amount of possible elements), must be known at compile-time.
In other words: you cannot change the size of an array by adding some element to it.
So, back to your question:
What does the @ symbol do?
It converts an array (e.g. [1, 2, 3]) to a sequence (@[1, 2, 3]). From the sequences chapter: