Skip to content

Comments

Pass all tests#95

Open
RupertSaxton wants to merge 2 commits intopaircolumbus:masterfrom
RupertSaxton:RupertLetsDrill
Open

Pass all tests#95
RupertSaxton wants to merge 2 commits intopaircolumbus:masterfrom
RupertSaxton:RupertLetsDrill

Conversation

@RupertSaxton
Copy link

letsdrill.rb Outdated

#Put your code here!
sorted = array.sort { | x, y | x.length <=> y.length }
sorted[0]
Copy link

Choose a reason for hiding this comment

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

This is pretty solid. But take a look through the ruby Enumerable docs and see if you can find an even more apt choice of method.

"B"
else
"A"
end
Copy link

Choose a reason for hiding this comment

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

Case statement might be more appropriate once the elsifs start stacking up, but this is fine.


sorted = array.sort { | x, y | x.length <=> y.length }
sorted[0]
array.min_by { |a| a.length }
Copy link

Choose a reason for hiding this comment

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

🎊

Copy link

Choose a reason for hiding this comment

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

...or even array.min_by(&:length)

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