Hello --

On Thu, 25 Apr 2002, Aron Griffis wrote:

> Hello,
>
> I'm attempting to implement a game called "Twixt".  There are lots of
> pages on the web describing the game, for example Google's first hit is
>
>     http://www.flash.net/~markthom/html/twixt.html
>
> I've read through some of the archives of this list and found an
> implementation of a Matrix class that seems to meet my needs.  Here's
> how I'm trying to use it:
>
>   class Matrix < Array
...
>   class TwixtBoard < Matrix
...

>   board = TwixtBoard.new
>   print board, "\n"

Or:

   puts board

:-)

>   tb[0,0] = RED
>   tb[23,23] = BLACK
>   print board, "\n"
>
> When I attempt to execute this code, I get the following error:
>
>   ./mat.rb:5:in `[]=': wrong # of arguments(2 for 3) (ArgumentError)
>           from ./mat.rb:5:in `initialize'
>           from ./mat.rb:4:in `each_index'
>           from ./mat.rb:4:in `initialize'
>           from ./mat.rb:24:in `initialize'
>           from ./mat.rb:40:in `new'
>           from ./mat.rb:40
>
> The problem appears to be that my overridden []= operator is
> propagating back into the Matrix class.  I'm sure this is a beginner's
> error, but what am I doing wrong?

It's not propagating back -- it's just that your board is a
TwixtBoard, not a matrix, so its idea of []= is the one you've defined
for TwixtBoard.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav