On Sun, Nov 6, 2011 at 15:59, steve ross <cwdinfo / gmail.com> wrote:

> Sorry to be late to the party on this one, but a regex seems a bit of a big hammer.

My thoughts exactly.

> How about:
>
> def article_for(noun)
> article = %w(a e i o u).include?(noun[0..0]) ? 'an' : 'a'
> "#{article} #{noun}"
> end

You and I might certainly do it that way, but I was trying to avoid
confusing her with %w and the ternary operator.  More newbie-friendly
would be:

def article_for noun
  if ['a', 'e', 'i', 'o', 'u'].include? noun[0..0]
    'an'
  else
    'a'
  end
end

-Dave

-- 
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)