tsetter.nim 245 B

1234567891011
  1. block: # ensure RHS of setter statement is treated as call operand
  2. proc `b=`(a: var int, c: proc (x: int): int) =
  3. a = c(a)
  4. proc foo(x: int): int = x + 1
  5. proc foo(x: float): float = x - 1
  6. var a = 123
  7. a.b = foo
  8. doAssert a == 124