Array iterate grammar rules

If i had an array containing a lot of words, and i wanted to add grammar
rules to those words, ie make words plural how would i duplicate the
original element and then modify that element with the grammar rule, and
id hope to iterate this for all the words and apply grammar rules via a
defined method.

IE:

array = [“sky”,“knife”,“kitty”]

after applying gsub or some other method such as inject or collect…the
array would become…

array #=> [“sky”,“skies”,“knife”,“knives”,“kitty”,“kitties”]
and whatnot ect ect.

id rather not gsub all the grammar rules lol.

Any ideas?

Thanks!

-Mac

On Nov 6, 9:16 pm, Michael L. [email protected] wrote:

after applying gsub or some other method such as inject or collect…the
array would become…

array #=> [“sky”,“skies”,“knife”,“knives”,“kitty”,“kitties”]
and whatnot ect ect.

id rather not gsub all the grammar rules lol.

irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> require ‘active_support’
=> true
irb(main):003:0> array = [“sky”,“knife”,“kitty”]
=> [“sky”, “knife”, “kitty”]
irb(main):004:0> plurals = array.map{ |word| word.pluralize }
=> [“skies”, “knives”, “kitties”]
irb(main):005:0> array
=> [“sky”, “knife”, “kitty”]
irb(main):006:0> array.zip( plurals )
=> [[“sky”, “skies”], [“knife”, “knives”], [“kitty”, “kitties”]]
irb(main):007:0> array.zip( plurals ).flatten
=> [“sky”, “skies”, “knife”, “knives”, “kitty”, “kitties”]