Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatting and grammar fixes #730

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions concepts/more-arrays/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,25 @@ We can do the same thing with arrays to expand a slice of the array.
myarray=(one two three four)

subarray=("${myarray[@]:0:2}")
declare -p subarray # => subarray=([0]="one" [1]="two")
declare -p subarray
# => declare -a subarray=([0]="one" [1]="two")

subarray=("${myarray[@]:1:3}")
declare -p subarray # => subarray=([0]="two" [1]="three" [2]="four")
declare -p subarray
# => declare -a subarray=([0]="two" [1]="three" [2]="four")
```

Omitting the length part means "from the offset to the end of the array":

```bash
subarray=("${myarray[@]:2}")
declare -p subarray # => subarray=([0]="three" [1]="four")
declare -p subarray
# => declare -a subarray=([0]="three" [1]="four")
```

## Passing an Array to a Function

This is not as straightforward as other languages you might be know.
This is not as straightforward as other languages you might know.
There are two main techniques to pass an array to a function.

### Pass the Elements
Expand Down
11 changes: 7 additions & 4 deletions concepts/more-arrays/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,25 @@ We can do the same thing with arrays to expand a slice of the array.
myarray=(one two three four)

subarray=("${myarray[@]:0:2}")
declare -p subarray # => subarray=([0]="one" [1]="two")
declare -p subarray
# => declare -a subarray=([0]="one" [1]="two")

subarray=("${myarray[@]:1:3}")
declare -p subarray # => subarray=([0]="two" [1]="three" [2]="four")
declare -p subarray
# => declare -a subarray=([0]="two" [1]="three" [2]="four")
```

Omitting the length part means "from the offset to the end of the array":

```bash
subarray=("${myarray[@]:2}")
declare -p subarray # => subarray=([0]="three" [1]="four")
declare -p subarray
# => declare -a subarray=([0]="three" [1]="four")
```

## Passing an Array to a Function

This is not as straightforward as other languages you might be know.
This is not as straightforward as other languages you might know.
There are two main techniques to pass an array to a function.

### Pass the Elements
Expand Down