Peña, Botp
10/6/2004 9:29:00 AM
Fredrik Jagenheim <jagenheim@gmail.com> wrote:
> | Given this array:
> | foo = %w { FOO BAR baz biz }
> |
> | How do I make all the entries uppercase in a short and readable way?
> |
> | The (to me) obvious solution won't work:
> | foo.map! { |x| x.upcase! }
> | as upcase returns nil if it doesn't have anything to upcase...
> | //F
try,
irb(main):004:0> foo.each{|x| x.upcase!}
=> ["FOO", "BAR", "BAZ", "BIZ"]
> Thomas
kind regards -botp