Browse Source

docs(array-selector): improve subject clarity

DEV-4191-DeepInSystem
nprimo 1 year ago committed by Niccolò Primo
parent
commit
3d6b963da9
  1. 18
      subjects/devops/array-selector/README.md

18
subjects/devops/array-selector/README.md

@ -5,15 +5,15 @@
Create a script `array-selector.sh`, which will have an array declared with the
following values (in this order): `red`, `blue`, `green`, `white`, `black`.
When executed, the script will try to print the element in the position specified in the first argument passed to the script.
When executed, the script will try to print the element at the position specified in the first argument passed to the script. The script will interpret the position `1` as the element in the array position `0`.
The script should return `Error` when:
- the number of argument passed are different from one,
- the number of given arguments is different from one,
- the argument passed is not a number,
- the given argument is not a number,
- the argument passed is a number out of the array range.
- the given argument is a number outside the range of the array.
Expected output:
@ -24,7 +24,7 @@ $ ./array-selector.sh 5
black
$ ./array-selector.sh 6
Error
$ ./array-selector.sh
$ ./array-selector.sh
Error
$
```
@ -38,8 +38,8 @@ $
array=("one" "two" "three")
echo ${array[0]} # display element in postion 0
echo ${array[2]} # display element in position 2
echo ${array[0]} # display element in position 0
echo ${array[2]} # display element in position 2
echo ${#array[@]} # display length of array
```
@ -59,7 +59,7 @@ three
if [[ 1 > 2 ]]; then
echo "true"
else
else
echo "false"
fi
```
@ -67,7 +67,7 @@ fi
And its output:
```console
$ bash script.sh
$ bash script.sh
false
```

Loading…
Cancel
Save