Skip to content

Instantly share code, notes, and snippets.

@mehagel
Created May 6, 2013 21:25
Show Gist options
  • Save mehagel/5528329 to your computer and use it in GitHub Desktop.
Save mehagel/5528329 to your computer and use it in GitHub Desktop.
def shortest_string(array)
i=0
if array.length > i
return (array.min_by {|x| x.length })
else
return nil
end
end
puts shortest_string(["cat","dog","horse","pig","elephant","rabbit"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment