- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 9
 
Array
        IsaacShelton edited this page Nov 16, 2022 
        ·
        7 revisions
      
    Array represents the type of an array.
| Type | Size | Possible Values | Memory Management Model | File | 
|---|---|---|---|---|
Array | 
32 bytes | Arrays of a Single Type | None | 2.7/Array.adept | 
record <$T> Array (items *$T, length usize)
where
$T is any valid type
| Name | Type | Description | 
|---|---|---|
items | 
*$T | 
Pointer to raw array of items | 
length | 
usize | 
Length of items in units | 
func __array__(this *<$T> Array) *$Tfunc __length__(this *<$T> Array) usizefunc __access__(this *<$T> Array, index usize) *$Timplicit func __as__(initializer <$T> InitializerList) <$T> Arrayimplicit func __as__(initializer <long> InitializerList) <int> Arrayimplicit func __as__(initializer <double> InitializerList) <float> Array
Arrays can be created from initializer lists:
food <String> Array = {"Spaghetti", "Pizza", "Garlic Bread"}
board <<int> List> Array = {
    {0, 0, 0, 0} as <int> Array,
    {0, 0, 0, 0},
    {0, 0, 0, 0},
    {0, 0, 0, 0}
}
Arrays have no memory management. The programmer is responsible for managing the memory that the array references.
- 
func get(this *<$T> Array, index usize) $TGets an item from an Array.
 - 
func getPointer(this *<$T> Array, index usize) *$TGets a pointer to an item in an Array.
 - 
func contains(this *<$T> Array, value $~T) boolReturns whether an Array contains an item that is equal to
value. - 
func applyDefer(this *<$T> Array) voidCalls
__defer__on every element of an array 
#default array_bounds_checks true
#default array_error_with_type __typeinfo__