mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-25 10:25:23 +00:00
Merge pull request #1212 from arthur-vieira/patch-1
Add #push to Array besides shovel operator
This commit is contained in:
commit
96ad94ad86
@ -173,6 +173,8 @@ array[1..3] #=> [2, 3, 4]
|
|||||||
|
|
||||||
# Add to an array like this
|
# Add to an array like this
|
||||||
array << 6 #=> [1, 2, 3, 4, 5, 6]
|
array << 6 #=> [1, 2, 3, 4, 5, 6]
|
||||||
|
# Or like this
|
||||||
|
array.push(6) #=> [1, 2, 3, 4, 5, 6]
|
||||||
|
|
||||||
# Check if an item exists in an array
|
# Check if an item exists in an array
|
||||||
array.include?(1) #=> true
|
array.include?(1) #=> true
|
||||||
|
Loading…
Reference in New Issue
Block a user