Skip to content

Conversation

@sophiabaldonado
Copy link

Sophia Baldonado

It was kind of weird to have to go through the linked list checking values until it reached the last node, then since the while loop breaks as soon as it gets there, it doesn't check the last node's value, so I had to do another check on the last node's value after the while loops in include and max. I think there must be a better way for me to implement them.

@sudocrystal
Copy link

REALLY great observation! -- if you change your loop to while current != nil instead of while current.next_node != nil then you wouldn't need that! I told you to model after display which does it the latter way -- because sometimes you need to do something different with the last case and I wanted that to be the pattern I showed -- but now I want to point out how we could have optimized the pattern just slightly. Hopefully that makes sense!

puts "Shows the size:"
puts ll.size


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay more tests!

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.

2 participants