-
Notifications
You must be signed in to change notification settings - Fork 47
Ports - Laneia #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Ports - Laneia #38
Conversation
|
Looks good! The only suggestion I have is you might want to consider changing the i variable to have a descriptive name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few style nits, but passes tests + LGTM overall. Nice work! 👍
Also, +1 to what @kdow said. 😃
| # and the same integer values in the same exact order | ||
| def array_equals(array1, array2) | ||
| raise NotImplementedError | ||
| i = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this can probably be declared closer to where it's used 😄
| raise NotImplementedError | ||
| i = 0 | ||
|
|
||
| if (array1 == nil && array2 == nil) || (array1 == [] && array2 == []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good boundary checking!
Super-tiny nit: it's somewhat explicit though - could we do something more concise, like:
if (array1 == array2)
return true
end
(Aside: some people think explicit code is easier to read, while
others prefer more concise code - so this comment is really a
matter of personal preference. 😄 )
| return false | ||
| end | ||
|
|
||
| if array1.length == array2.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: nested ifs are harder to understand at a glance. How about something like:
if array1.length != array2.length
return false
end
# array lengths presumed equal, because of above "guarding" if statement
...
| if array1[i] != array2[i] | ||
| return false | ||
| end | ||
| i += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: typically people use a "for" loop here rather than manually doing i += 1 (it's more concise, which makes it easier to identify at a glance)
| return false | ||
| end | ||
|
|
||
| array3 = [10, 20, 30, 40, 50, 60] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice testing! 😄
Aside: typically we'll put our tests in a separate file. This is
important because some languages (e.g. Python and Javascript) automatically
execute top-level code in loaded files/libraries.
e.g. if fileB imports fileA, top-level code (that's not in a function)
in fileA will automatically be executed in such languages. (In some cases, this is what you want - in others, it isn't.)
No description provided.