Skip to content

Helper Functions

justinmann edited this page Dec 24, 2017 · 1 revision

Sometimes you need to add functionality to an existing class, but cannot modify the original implementation. Or you need to add functionality to a basic type like i32/f32.

i32_bob(x : 'i32) { x.asString() + "bob" }
5.bob() // "5bob"

string_multiplyI32(s : 'string, x : 'i32) {
    s + " times " + x.asString()
}
"hello" * 5 // "hello times 5"

Clone this wiki locally