-
Notifications
You must be signed in to change notification settings - Fork 47
Sockets - Kate N #41
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?
Sockets - Kate N #41
Conversation
lib/array_equals.rb
Outdated
| # and the same integer values in the same exact order | ||
| def array_equals(array1, array2) | ||
| raise NotImplementedError | ||
| if array1 == nil || array2 == nil |
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.
When I think about how to write effective if-statements, I normally think of the flow like a triangle, where the stricter conditions should be going first, and the less strict conditions follow. The reason is if what you want to check does not meet the stricter conditions, you can quickly return the result without wasting time moving through the rest of the less strict conditions.
Applying the principle above to this particular problem, I will put the && before the | |.
lib/array_equals.rb
Outdated
| return true | ||
| elsif array1 == [] && array2 == [] | ||
| return true | ||
| elsif array1 == nil || array2 == nil |
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.
The statements on line 9 & 10 seem contradictory to the statement on line 5 & 6. Could you please look into it?
lib/array_equals.rb
Outdated
| return false | ||
| index = 0 | ||
| while index < array_length | ||
| if array1[current_index] != array2[current_index] |
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.
I think you mean index (instead of current_index) here?
| # 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 |
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.
Make sure to remove the raise here, otherwise it will throw an exception.
| return true | ||
| end | ||
| end | ||
|
|
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.
Code is clear, concise and easy to read. Good work!
No description provided.