mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-29 18:11:44 +00:00
18 lines
231 B
Nim
18 lines
231 B
Nim
discard """
|
|
output: '''x: 0 y: 0'''
|
|
"""
|
|
|
|
proc toString*[T](x: T): string = return $x
|
|
|
|
|
|
type
|
|
TMyObj = object
|
|
x, y: int
|
|
|
|
proc `$`*(a: TMyObj): string =
|
|
result = "x: " & $a.x & " y: " & $a.y
|
|
|
|
var a: TMyObj
|
|
echo toString(a)
|
|
|