Hello.
I don't understand the following operators, can you help me with examples?
'@' '~'
Thank you. Best regards.
Antonio F.S.
Please provide more context.
In Nim you can define / override the behaviour for operators based on the type of the operand(s), so we need to see the code where the operator is used.
The manual is rather clear about the semantics in this case.
Basically, operators are just regular functions that are named with any combination of the symbols in this list:
= + - * / < > @ $ ~ & % | ! ? ^ . : \
∙ ∘ × ★ ⊗ ⊘ ⊙ ⊛ ⊠ ⊡ ∩ ∧ ⊓ # same priority as * (multiplication)
± ⊕ ⊖ ⊞ ⊟ ∪ ∨ ⊔ # same priority as + (addition)
They are defined the same way, except that you'll probably need to use stroping (enclosing in backticks '`'):
proc `+%`(x, y: int): int
So, the basic @ versions (1, 2) defined in the implicitly-imported system module are just the shorthands for procedures for creating a sequence (seq) of type T from 1: regular array of T (generic over length/ordinal types IDX) and 2: any other type that can be treated as an openArray[T] (2).
Haven't seen the other operator (~) in the standard library, but the same logic applies.
Hello.
Well explained. I understand now. Thank you.
Best regards. Antonio F.S.
Hello again.
From the list of tokens displayed in the Nim manual, these two I don't understand: (. .) [:
Any explanation and especially examples, please?
Best regards. Antonio F.S.
Hello.
Perfect explanation.
Thank you very much.
Best regards. Antonio F.S.