From 79b6085446666a0e545aa77b5d3571db66d6a026 Mon Sep 17 00:00:00 2001 From: Naheed Arang Date: Wed, 22 Aug 2018 23:25:12 -0700 Subject: [PATCH] completed method --- lib/array_equals.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..caae42b 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) - raise NotImplementedError + if array1 == nil && array2 == nil + return true + elsif array1 == nil || array2 == nil + return false + elsif array1 == [] && array2 == [] + return true + elsif array1 == [] && array2 != [] + return false + elsif array1.length != array2.length + return false + end + + array1.length.times do |i| + if array1[i] == array2[i] + i += 1 + return true + else + return false + end + end end