From 1b1d10e2d9b7493039382f0f6020e82d317d0c52 Mon Sep 17 00:00:00 2001 From: Rahil Momin Date: Thu, 19 Mar 2015 15:37:42 +0530 Subject: [PATCH] add include? method on arrays --- ruby.html.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ruby.html.markdown b/ruby.html.markdown index 1883d1ad..800f0445 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -169,6 +169,9 @@ array[1..3] #=> [2, 3, 4] # Add to an array like this 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 denoted with curly braces: hash = { 'color' => 'green', 'number' => 5 }