tnilstrs.nim 369 B

1234567891011121314151617181920212223242526
  1. block:
  2. var x: string
  3. var y = "foo"
  4. echo x
  5. doAssert x == ""
  6. doAssert "" == x
  7. add(x, y)
  8. y[0] = 'm'
  9. doAssert y == "moo" and x == "foo"
  10. block:
  11. var x = "foo".cstring
  12. var y: string
  13. add(y, x)
  14. doAssert y == "foo"
  15. block:
  16. type Foo = object
  17. a: string
  18. var foo = Foo(a: "foo")
  19. var y = move foo.a
  20. doAssert foo.a.len == 0
  21. doAssert y == "foo"