From: Rick DeNatale Date: 2006-09-16T01:22:47+09:00 Subject: Re: not finding a breakpoint + values are nil On 9/14/06, Dan Bensen wrote: > Ruby seems to be passing over a breakpoint in a class initialize > function. "Got grid" is the only break that occurs before the program > hits a bug. What is Grid.new doing, and how come the "Grid initialized" > breakpoint wasn't found or didn't work? > > grid after "Got grid": > => [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]] > > In file controllers/t3_controller.rb: > ... > grid = Grid.new(gridStr) > breakpoint "Got grid" > ... > > In file controllers/t3/t3lib.rb: > > module Cell > class Val < String > def isBlank > self == BLANK > end > end > BLANK = Val.new(' ') > end > > class Grid < Array > def initialize(array = ()) > super(3) { |row| Array.new(3,Cell::BLANK) } > breakpoint "Grid initialized" Well I'm not sure what else is in your real code, but I just tried this, and it works. Not that I'm a big fan of subclassing core classes either: rick@frodo:/public/rubyscripts$ cat gridtest.rb require 'rubygems' require_gem 'ruby-breakpoint' module Cell class Val < String def isBlank self == BLANK end end BLANK = Val.new('') end class Grid < Array def initialize(array=()) super(3) {|row| Array.new(3, Cell::BLANK)} breakpoint "Grid initialized" end end grid = Grid.new("foo") breakpoint "Got grid #{grid.inspect}" rick@frodo:/public/rubyscripts$ ruby gridtest.rb Executing break point "Grid initialized" at gridtest.rb:17 in `initialize' irb():001:0> quit Executing break point "Got grid [[\"\", \"\", \"\"], [\"\", \"\", \"\"], [\"\", \"\", \"\"]]" at gridtest.rb:22 irb(main):001:0> quit rick@frodo:/public/rubyscripts$ By the way, what's up with the array=() parameter in initialize? 1) You don't seem to be using it, 2) The default value is () which is nil, did you mean []? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/