Examples

Methods

The receiver comes first. It borrows or it consumes.

main (print)

<counter: hits int>

# A method is a function with its receiver first. A borrowed receiver
# (&) reads; an owned receiver consumes and usually returns the next value.
(c &counter) show() none
    print.line("{c.hits}")

(c counter) bump() counter
    <*c, hits int: hits + 1>

main()
    c = <counter: hits = 0>
    c = c.bump().bump()
    c.show()
2