--kr14OxHsRwZHHqxS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I came up with this method really quick to create x*y arrays in Ruby. It
mimicks Array#new's behavior pretty closely wrt blocks, I hope. What do youll
think?

class << Array
    def multi(x,y,*args, &block)
        if args.length > 0 and block_given?
            raise ArgumentError, "wrong number of arguments (#{args.length + 2} for 2)"
        elsif args.length > 1 and not block_given?
            raise ArgumentError, "wrong number of arguments (#{args.length + 2} for 3)"
        end

        Array.new(x) do
            if block_given?
                Array.new(y, &block)
            else
                Array.new(y, args[0])
            end
        end
    end
end

Usage is:

Array.multi(5,5,0)  
# => [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0],0, 0, 0, 0, 0]]
Array.multi(5,5) {""}
# => [["", "", "", "", ""], ["", "", "", "", ""], ["", "", "", "", ""], ["", "", "", "", ""], ["", "", "", "", ""]]

-- 
panic ("No CPUs found.  System halted.\n");
        2.4.3 linux/arch/parisc/kernel/setup.c

--kr14OxHsRwZHHqxS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGfr77KaiGM/xGKzQRApS2AJoD7vFPvqOjYJs2DShP5FFJPjTPDwCgoy5c
RKfZw/CmHzE9o1AhY3tfz8Qウ
ュュュュュナホト ミヌミ モノヌホチヤユメナュュュュュ

ュュアエマネメレネネモュュ