Re: not finding a breakpoint + values are nil



On 9/14/06, Dan Bensen <randomgeek@xxxxxxxxxxxxxx> 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/

.



Relevant Pages

  • Re: VFP 8.0 grid losing focus and forcing a tableupdate()
    ... Putting a breakpoint on any code that executes between the ... it works fine in VFP 9. ... > grid loses focus? ... >> I have a row buffered cursor. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: VFP 8.0 grid losing focus and forcing a tableupdate()
    ... > If I put VFP in a window so I can see the watch pane of the debugger I can ... Putting a breakpoint on any code that executes between the ... >> grid loses focus? ...
    (microsoft.public.fox.programmer.exchange)
  • not finding a breakpoint + values are nil
    ... Ruby seems to be passing over a breakpoint in a class initialize function. ... What is Grid.new doing, and how come the "Grid initialized" breakpoint wasn't found or didn't work? ...
    (comp.lang.ruby)
  • [OT] Re: not finding a breakpoint + values are nil
    ... What is Grid.new doing, and how come the "Grid initialized" breakpoint wasn't found or didn't work? ... -- wei wu wei ...
    (comp.lang.ruby)
  • Re: Virtual grid
    ... just ditch the array & load the data directly to the grid. ... Populating the grid from a file will be somewhat slower than from an array (memory), ... > want to display it in a flexgrid control. ...
    (microsoft.public.vb.controls)