tinterf.nim 492 B

12345678910111213141516171819202122232425
  1. discard """
  2. output: '''56 66'''
  3. """
  4. type
  5. ITest = tuple[
  6. setter: proc(v: int) {.closure.},
  7. getter1: proc(): int {.closure.},
  8. getter2: proc(): int {.closure.}]
  9. proc getInterf(): ITest =
  10. var shared1, shared2: int
  11. return (setter: proc (x: int) =
  12. shared1 = x
  13. shared2 = x + 10,
  14. getter1: proc (): int = result = shared1,
  15. getter2: proc (): int = return shared2)
  16. var i = getInterf()
  17. i.setter(56)
  18. echo i.getter1(), " ", i.getter2()