I\'m trying to create method named longest_word that takes a sentence as an argument and The function will return the longest word of the sentence.
longest_word
My c
If you truly want to do it in the Ruby way it would be:
def longest(sentence) sentence.split(' ').sort! { |a, b| b.length <=> a.length }[0] end