-
-
Notifications
You must be signed in to change notification settings - Fork 9
Intrinsic Procedure __access__
IsaacShelton edited this page Mar 21, 2022
·
1 revision
The __access__
method can be defined to allow additional types to be used with the element access []
and pointer element access at
operators.
func __access__(this *StructValue, index $I) *$T {
}
where
-
$T
is the element type of the collection -
$I
is the index type
The return value is a pointer to the element identified by the given index value.
The following is a simple example of what a definition of the __access__
method might look like:
struct <$T> Array (items *$T, length usize) {
/* ... other methods ... */
func __access__(index usize) *$T = this.items at index
}
This example is a reduced version of the __access__
method for the standard Array
type.