Mega Code Archive

 
Categories / Ruby / Array
 

Check an Array for a Certain Item

# The include? method returns true if the supplied parameter is in the array,  # and false otherwise: x = [1, 2, 3] puts x.include?("x") puts x.include?(3)