From: grady@... (Steven Grady) Date: 2000-12-20T06:10:03+09:00 Subject: [ruby-talk:7716] Re: Code sample for improvement How about using a default plural construction, and factoring out the #{size} in result? Changes lines are commented with "!!!": #! /usr/bin/env ruby # Given the number of seconds, convert to English description # !!! simpler table table = [ [ 31557816, 'year' ], [ 2629818, 'month' ], [ 86400, 'day' ], [ 3600, 'hour' ], [ 60, 'min' ], [ 1, 'sec' ] ] result = "" time = ARGV[0].to_i table.each {|unit, sing, plur| plur = sing+'s' if !plur; # !!! size = time / unit if size > 0 result += "#{size} #{(size == 1) ? sing : plur} " # !!! end time %= unit } puts result -- Steven "I can't think of anything more relaxing than being locked in a moving car with YOU for about 300 hours, little pal." "That's really sweet, Sam. I may weep openly."