From 3d41ca001f74fff1b0d410430e14a8fcb38be249 Mon Sep 17 00:00:00 2001 From: Samantha Coll Date: Sun, 1 Sep 2019 13:46:05 -0700 Subject: [PATCH 1/3] "implemented array_equals method, tests pass" --- lib/array_equals.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..d2c4161 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,21 @@ # 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 == array2) + return true + elsif (array1 == nil || array2 == nil) + return false + end + + if (array1.length != array2.length) + return false + end + + array1.each_with_index do |number, i| + if array1[i] != array2[i] + return false + end + end end From 56832f0159a2357ea0b79a8ddf81300e1eabc925 Mon Sep 17 00:00:00 2001 From: Samantha Coll Date: Thu, 5 Sep 2019 11:55:19 -0700 Subject: [PATCH 2/3] added return true at the end of method --- lib/array_equals.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index d2c4161..3fb1ee8 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -17,5 +17,6 @@ def array_equals(array1, array2) if array1[i] != array2[i] return false end + return true end end From cde4061b7d2c4ea3d425483a4576e060ff518ac5 Mon Sep 17 00:00:00 2001 From: Samantha Coll Date: Tue, 24 Sep 2019 11:00:57 -0700 Subject: [PATCH 3/3] fixing bug on array_equals method --- lib/array_equals.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 3fb1ee8..62bc173 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -18,5 +18,5 @@ def array_equals(array1, array2) return false end return true - end + end end