resultreject.nim 688 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. errormsg: "has to be used (or discarded)"
  3. line: 27
  4. """
  5. # Page 35.
  6. proc implicit: string =
  7. "I will be returned"
  8. proc discarded: string =
  9. discard "I will not be returned"
  10. proc explicit: string =
  11. return "I will be returned"
  12. proc resultVar: string =
  13. result = "I will be returned"
  14. proc resultVar2: string =
  15. result = ""
  16. result.add("I will be ")
  17. result.add("returned")
  18. proc resultVar3: string =
  19. result = "I am the result"
  20. "I will cause an error"
  21. doAssert implicit() == "I will be returned"
  22. doAssert discarded() == nil
  23. doAssert explicit() == "I will be returned"
  24. doAssert resultVar() == "I will be returned"
  25. doAssert resultVar2() == "I will be returned"