add include? method on arrays

This commit is contained in:
Rahil Momin 2015-03-19 15:37:42 +05:30
parent a6ea67e733
commit 1b1d10e2d9

View File

@ -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 }