Skip to content

Conversation

@spudfkc
Copy link

@spudfkc spudfkc commented Mar 1, 2018

#Put your code here!

unless array.nil?
array.min_by { |s| s.length }
Copy link
Member

Choose a reason for hiding this comment

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

nice use of min_by!

theoretically, you could also check for if array. i'd like to call attention to two things.

  1. there's a lot of great options when working in rails - https://stackoverflow.com/questions/885414/a-concise-explanation-of-nil-v-empty-v-blank-in-ruby-on-rails
  2. there's something to keep in mind when using unless.
    http://www.railstips.org/blog/archives/2008/12/01/unless-the-abused-ruby-conditional/

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