From 76c8c2dc18b1aa83724fc83eeb0109491bb51043 Mon Sep 17 00:00:00 2001 From: Anibel America Date: Wed, 22 Aug 2018 08:50:13 -0700 Subject: [PATCH] Implements method for determining if 2 arrays are equal --- lib/array_equals.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..df9c04b 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,24 @@ # Determines if the two input arrays have the same count of elements # and the same integer values in the same exact order def array_equals(array1, array2) + if array1 == nil && array2 == nil + return true + elsif array1 == nil || array2 == nil + return false + end + + array1_length = array1.length + array2_length = array2.length + if array1_length == array2_length + array1_length.times do |index| + if array1[index] != array2[index] + return false + end + end + return true + end + return false + raise NotImplementedError + end