docs: document is operator as overridable infix method and add type-test examples
This commit is contained in:
@@ -123,7 +123,7 @@ We also have a slew of infix operators—they have operands on both sides.
|
||||
They are:
|
||||
|
||||
:::wren
|
||||
== != < > <= >= .. ... | & + - * / %
|
||||
== != < > <= >= .. ... | & + - * / % is
|
||||
|
||||
Like prefix operators, they are all funny ways of writing method calls. The left
|
||||
operand is the receiver, and the right operand gets passed to it. So `a + b` is
|
||||
@@ -138,6 +138,13 @@ objects, but they are method calls like other operators.
|
||||
|
||||
[range]: values.html#ranges
|
||||
|
||||
The `is` keyword is a "type test" operator. The base [Object][] class implements
|
||||
it to tell if an object is an instance of a given class. You'll rarely need to,
|
||||
but you can override `is` in your own classes. That can be useful for things
|
||||
like mocks or proxies where you want an object to masquerade as a certain class.
|
||||
|
||||
[object]: core/object.html
|
||||
|
||||
## Subscripts
|
||||
|
||||
Another familiar syntax from math class is *subscripting* using square brackets
|
||||
|
||||
Reference in New Issue
Block a user