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

successfully completed #108

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

Conversation

matthewlee07
Copy link

Thanks for the review!

"F"
else
"Invalid Input"
end
Copy link

@sjreich sjreich Sep 28, 2018

Choose a reason for hiding this comment

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

Nice, clean solution.

Tackling the invalid inputs is an extra step, but let's talk about the best way to do that. This might be a good case for using a guard clause up front - something like return 'Invalid Input' unless integer.is_a? Integer. But that gets me thinking about what the desired behavior would actually be here. Obviously, this all depends on what sort of broader program this method would appear in, but my hunch is that in most use cases, either returning nil or raising a TypeError would be more helpful than returning a different string.

letsdrill.rb Outdated

#Put your code here!

array.sort_by {|string| string.length}[0]
Copy link

Choose a reason for hiding this comment

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

Nice. Ruby has first, so that is typically preferred to [0] for stylistic reasons. But also, scan through the ruby Enumerable documentation, and see if you can't find a method that is even more fitting than what you have here.

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