Not finding a breakpoint + values are nil

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”

On Fri, 15 Sep 2006, Dan B. wrote:

grid = Grid.new(gridStr)
end
BLANK = Val.new(’ ')
end

class Grid < Array
def initialize(array = ())
super(3) { |row| Array.new(3,Cell::BLANK) }
breakpoint “Grid initialized”

if you haven’t used narray you should check it out - it’ll give you
beautiful
numerical grids with blinding speed in few lines of code…

fyi.

-a

On Sep 14, 2006, at 5:45 PM, Dan B. 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?

Is this perhaps an issue of inheriting from a core class? I know
there are lots
of gotcha’s when you do this because the normal method dispatch tends
to be bypassed.
Maybe try delegating to Array instead.

Gary W.

Rick DeNatale wrote:

Well I’m not sure what else is in your real code, but I just tried
this, and it works.

Does it work in a Rails app? Breakpoints in the controller file work,
and everything else works from the command line, but other than
breakpoints in the controller file, I haven’t gotten anything to work
from Rails:

  • breakpoints
  • printing to standard output
  • printing to a log file
  • made the class free-standing, not derived from anything
  • require ‘breakpoint’
  • require ‘rubygems’; require_gem ‘ruby-breakpoint’

Nothing. Not one single thing has worked outside the controller file.
And there’s not even a useful error message, just an “Internal Server
Error” on the client. I have no idea what I’m missing. Is there some
special place the files have to be? I have them in a subdirectory of
controllers.

On Sep 15, 2006, at 1:55 PM, Dan B. wrote:

  • breakpoints
    them in a subdirectory of controllers.


My name is dsb, and I’m at prairienet, which is an O-R-G.

Breakpoint is broken in ruby1.8.5. Maybe that is your issue?

-Ezra

On 9/14/06, Dan B. [email protected] wrote:

grid = Grid.new(gridStr)
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/

Ezra Z. wrote:

Breakpoint is broken in ruby1.8.5. Maybe that is your issue?

I have 1.8.4.

Well, I made a little test app that works. I’ll try building that up
and see if it breaks at some point.

Dan B. wrote:

Ruby seems to be passing over a breakpoint …
Okay, it looks like require doesn’t look for a new copy of a file when
you edit it. load seems to work, but is there a way to make sure you
only load once, other than C-style tricks?