Refine docs.

This commit is contained in:
Stephen Chung
2020-12-26 23:21:16 +08:00
parent 66d3af256e
commit 88f63fa24b
16 changed files with 116 additions and 58 deletions

View File

@@ -3,18 +3,19 @@ Override a Built-in Function
{{#include ../links.md}}
Any similarly-named function defined in a script overrides any built-in or registered
Any similarly-named function defined in a script _overrides_ any built-in or registered
native Rust function of the same name and number of parameters.
```rust
// Override the built-in function 'to_int'
fn to_int(num) {
print("Ha! Gotcha! " + num);
// Override the built-in function 'to_float' when called as a method
fn to_float() {
print("Ha! Gotcha! " + this);
42.0
}
let x = (123).to_int();
let x = 123.to_float();
print(x); // what happens?
print(x); // what happens?
```
A registered native Rust function, in turn, overrides any built-in function of the