simple-exercises/ruby-exercises/very-easy.rb
# Write a method that takes in a string. Return the longest word in
# the string. You may assume that the string contains only letters and
# spaces. You may use the String `split` method to aid you in your quest.
Write a method that takes in a string. Return the longest word in
the string. You may assume that the string contains only letters and
spaces. You may use the String `split` method to aid you in your quest.
Write a method that takes in a string . Return the longest word in the string . You may assume that the string contains only letters and spaces . You may use the String ` split ` method to aid you in your quest .
def longest_word sentence
  words = sentence.split
  longest = ""
  length = 0
  words.each do |word|
    if word.length > length
      longest = word
      length = word.length
    end
  end
  longest
end
def longest_word sentence words = sentence . split longest = "" length = 0 words . each do | word | if word . length > length longest = word length = word . length end end longest end
Write a method that takes in a string.
Write a method that takes in a string .
sentence
<not_specific>