implemented Unicode operators (#18789)
* implemented Unicode operators; refs https://github.com/nim-lang/RFCs/issues/388 * bugfix * better test * arguably more elegant implementation * Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
parent
905fae51f6
commit
c2b20516d3
6 changed files with 117 additions and 7 deletions
14
tests/lexer/tunicode_operators.nim
Normal file
14
tests/lexer/tunicode_operators.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#{.experimental: "unicodeOperators".}
|
||||
|
||||
proc `⊙`(x, y: int): int = x * y
|
||||
proc `⊙=`(x: var int, y: int) = x *= y
|
||||
|
||||
proc `⊞++`(x, y: int): int = x + y
|
||||
|
||||
var x = 45
|
||||
x ⊙= 9 ⊞++ 4 ⊙ 3
|
||||
|
||||
var y = 45
|
||||
y *= 9 + 4 * 3
|
||||
|
||||
assert x == y
|
||||
Loading…
Add table
Add a link
Reference in a new issue