Skip to content
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

Sockets - Kate N #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

KateAnnNichols
Copy link

No description provided.

@@ -2,4 +2,51 @@
# and the same integer values in the same exact order
def array_equals(array1, array2)
raise NotImplementedError
if array1 == nil || array2 == nil
Copy link

@ChubbyCub ChubbyCub Mar 1, 2019

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 | |.

return true
elsif array1 == [] && array2 == []
return true
elsif array1 == nil || array2 == nil

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?

return false
index = 0
while index < array_length
if array1[current_index] != array2[current_index]

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?

@@ -2,4 +2,42 @@
# and the same integer values in the same exact order
def array_equals(array1, array2)
raise NotImplementedError

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.

end

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants