#250: subclassing Array
-------------------------------------+--------------------------------------
Reporter: mattaimone...@… | Owner: lsansone...@…
Type: defect | Status: new
Priority: major | Milestone:
Component: MacRuby | Keywords: subclassing, Array
-------------------------------------+--------------------------------------
{{{
class Board < Array
def initialize(*args)
super
0.upto(7) do
self << (0..7).map{[]}
end
end
end
b = Board.new
}}}
{{{
./miniruby -I./lib -e "class Board < Array; def initialize(*args); super;
0.upto(7) do; self << (0..7).map{[]}; end; end; end; p Board.new"
# => []
}}}
{{{
macruby -e "class Board < Array; def initialize(*args); super; 0.upto(7)
do; self << (0..7).map{[]}; end; end; end; p Board.new"
# => []
}}}
{{{
ruby19 -e "class Board < Array; def initialize(*args); super; 0.upto(7)
do; self << (0..7).map{[]}; end; end; end; p Board.new"
# => [[[], [], [], [], [], [], [], []], [[], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], []], [[], [], [], [], [], [], [], []], [[],
[], [], [], [], [], [], []], [[], [], [], [], [], [], [], []], [[], [],
[], [], [], [], [], []]]
}}}
{{{
ruby -e "class Board < Array; def initialize(*args); super; 0.upto(7) do;
self << (0..7).map{[]}; end; end; end; p Board.new"
# => [[[], [], [], [], [], [], [], []], [[], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], []], [[], [], [], [], [], [], [], []], [[],
[], [], [], [], [], [], []], [[], [], [], [], [], [], [], []], [[], [],
[], [], [], [], [], []]]
}}}
I think the problem is pretty obvious, let me know if you need more
explanations.
--
Ticket URL: <http://www.macruby.org/trac/ticket/250>
MacRuby <http://macruby.org/>
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel