From 445d48aea5368f46c7de52bb55926e75045b6720 Mon Sep 17 00:00:00 2001 From: Riyo Date: Wed, 27 Feb 2019 20:28:39 -0800 Subject: [PATCH] finished method --- lib/array_equals.rb | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..7ecd7f8 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,26 @@ # 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) - raise NotImplementedError + if array1 == nil && array2 == nil + return true + exit + elsif array1 == nil && array2 != nil + return false + exit + elsif array1 != nil && array2 == nil + return false + exit + elsif array1.length != array2.length + return false + exit + else + index = 0 + array1.length.times do + if array1[index] != array2[index] + return false + exit + else index += 1 end + end + return true + end end