Write program to get the longest word in a sentence
The each iterator allows you to go through all the elements of an array and use the data you retrieve to work out.
my_array = %w{this is a test of the longest word check} longest_word = '' my_array.each do |word| # from w ww . j a v a 2 s. com longest_word = word if longest_word.length < word.length end puts longest_word