Skip to content

Commit fcea1ba

Browse files
authored
Update 581-data-append.markdown
1 parent cd432c6 commit fcea1ba

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed
Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,58 @@
11
# APPEND
22

3-
> APPEND a, val [, val [, ...]]
3+
> APPEND a, var1 [, var2 [, ..., varN]]
44
5-
Inserts the values at the end of the specified array.
5+
Inserts the values `var1` to `varN` at the end of the array `a`. `var1` to `varN` can be any data type.
6+
7+
Instead of APPEND the `<<` Operator can be used.
68

79

8-
* a - An array-variable.
9-
* val - Any value or expression
10+
### Example 1: Append single number
1011

1112
```
1213
a = [1,2,3]
1314
print "Before APPEND: "; a
1415
1516
APPEND a, 4
1617
print "After APPEND : "; a
18+
19+
' Output:
20+
' Before APPEND: [1,2,3]
21+
' After APPEND : [1,2,3,4]
1722
```
1823

19-
Instead of APPEND the `<<` Operator can be used.
24+
### Example 2: Append multiple numbers
25+
26+
```
27+
a = [1,2,3]
28+
29+
APPEND a, 4, 5
30+
print a ' Output: [1,2,3,4,5]
31+
```
32+
33+
### Example 3: Append an array
34+
35+
```
36+
a = [1,2,3]
37+
38+
APPEND a, [4,5,6]
39+
print a ' Output: [1,2,3,[4,5,6]]
40+
```
41+
42+
### Example 4: Append a string
43+
44+
```
45+
a = ["a", "b", "c"]
46+
47+
APPEND a, "d"
48+
print a ' Output: [a,b,c,d]
49+
```
50+
51+
### Example 5: Using << operator
2052

2153
```
2254
a = [1,2,3]
23-
print "Before << operaror: "; a
2455
2556
a << 4
26-
print "After << operator : "; a
57+
print a ' Output: [1,2,3,4]
2758
```

0 commit comments

Comments
 (0)