Commit 9a777eef authored by Michael Aaron Murphy's avatar Michael Aaron Murphy

Fix array assignment spec

parent d65b16fa
## Methods
[methods]: #methods
Ion also goes a step further and allows the shell to contain some very specific logic that can
be invoked by name: methods. As the shell is parsing a non-braced variable expansion, if it
discovers the `(` character then it will collect all text that follows until it meets the
corresponding `)`, and then executes a function whose name is equal to the text between
the sigil, up to the `(`. The values within the parenthesis are then used as arguments to the
method.
```
let replaced = $replace(string_var, github.com/redox-os gitlab.redox-os.org/redox-os)
let reversed = @reverse(array)
```
### Method Source
[method-source]: #method-source
The first parameter of a method will define the source to enact the method on. Each method has a
_preferred_ type for that method, which allows the user to ellide the sigil. The source does
not have to be a stored type, however, so it is possible to use a method's output as the
input for the source.
> NOTE: Should we use a comma to delimit the source parameter from the argument paramters?
### Method Arguments
[method-arguments]: #method-arguments
Each following parameter will also be evaluated and split accordingly, and used as the arguments
for the method. It's possible to use the output of process expansions and other methods.
......@@ -65,15 +65,22 @@ FOO BAR BAZ
### Array Index Assignment
[array-index-assignment]: #array-index-assignment
When assigning directly to an index in an array, if one value is supplied, that value will
be assigned to that index. If an array of values is supplied, the array will be inserted
at that location.
It is possible to assign a value directly to a specific position within an array.
```
$ let FOO = [4 5 6]
$ let FOO[0] = [1 2 3]
$ let FOO[0] = 1
$ echo @FOO
1 2 3 4 5 6
1 5 6
```
Multidimensional arrays may also be assigned to in the same manner.
```
$ let FOO = [[1 2 3] [4 5 6]]
$ let FOO[0] = [7 8 9]
$ echo @FOO
7 8 9 4 5 6
```
### Array Index Range Assignment
......@@ -156,13 +163,13 @@ let B:int[] = [5 2 3 1]
- **bool**: either `1` or `0`
- **float**: a generic decimal of any size
- **int**: a generic integer of any size, which may be negative
- **i32**: 32-bit int
- **i64**: 64-bit int
- **i128**: 128-bit int
- **i32**: 32-bit int
- **i64**: 64-bit int
- **i128**: 128-bit int
- **uint**: a generic integer of any size, which may not be negative
- **u32**: 32-bit uint
- **u64**: 64-bit uint
- **u128**: 128-bit uint
- **u32**: 32-bit uint
- **u64**: 64-bit uint
- **u128**: 128-bit uint
## Assignment Operators
[operators]: #operators
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment