Created
January 26, 2016 13:52
-
-
Save mistrikushal/e6a8cb75166f75e78bd9 to your computer and use it in GitHub Desktop.
find a longest word from a given string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# logic to check longest word from a string | |
str = 'this string contains a looooooong word' | |
longest_word = str.split(' ').max_by(&:length) | |
puts "Longest word of the string is: #{longest_word}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment