Ben Zealley wrote:
> Is there a nice elegant way of creating several named objects of the
> same class? I naively tried
>
> a,b,c,d = 0
> [a, b, c, d].each { |o| o = SomeClass.new }
>
> and found that while they get initialised inside the block, they get
> destroyed leaving it. I can't believe
>
> a = SomeClass.new
> b = SomeClass.new
> etc.
>
> is the best way to do it. I can populate an array, but let's
> hypothesise that for reasons relating to irritating corporate coding
> standards, the variables need specific names... ;)
>
> Thoughts appreciated! Cheers

Surely overkill but:

  require 'facet/enumerable/every

  a,b,c = ([SomeClass] * 3).every.new

T.