mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 01:51:38 +00:00
add include? method on arrays
This commit is contained in:
parent
a6ea67e733
commit
1b1d10e2d9
@ -169,6 +169,9 @@ 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]
|
||||||
|
|
||||||
|
# Check if an item exists in an array
|
||||||
|
array.include?(1) #=> true
|
||||||
|
|
||||||
# Hashes are Ruby's primary dictionary with keys/value pairs.
|
# Hashes are Ruby's primary dictionary with keys/value pairs.
|
||||||
# Hashes are denoted with curly braces:
|
# Hashes are denoted with curly braces:
|
||||||
hash = { 'color' => 'green', 'number' => 5 }
|
hash = { 'color' => 'green', 'number' => 5 }
|
||||||
|
Loading…
Reference in New Issue
Block a user