Skip to content

Commit

Permalink
Updated phrasing regarding overload.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Oct 1, 2024
1 parent cbaf80c commit bd7c904
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/content/docs/Generic Programming/operator-overloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ to get the last element assuming the indexing uses integers.

## Enabling 'foreach'

In order to use a type with foreach, e.g. `foreach(d : foo)`, at a minimum `[]` and `len` need to
be implemented. If `&[]` is implemented, foreach by reference is enabled (e.g. `foreach(double* &d : foo)`)
In order to use a type with foreach, e.g. `foreach(d : foo)`, at a minimum methods
with overloads for `[]` (`@operator([])`) and `len` (`@operator(len)`) need to be added.
If `&[]` is implemented, foreach by reference is enabled (e.g. `foreach(double* &d : foo)`)

```c3
fn double Foo.get(&self, usz i) @operator([])
Expand Down

0 comments on commit bd7c904

Please sign in to comment.