# Not finding a breakpoint + values are nil

**URL:** <https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731>\
**Category:** Ruby\
**Created:** [September 14, 2006, 11:46pm UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731 "2006-09-14T23:46:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 14, 2006, 11:46pm UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/1 "2006-09-14T23:46:39Z")

</div>

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”  
…

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 15, 2006, 12:06am UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/2 "2006-09-15T00:06:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 15, 2006, 12:26am UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/3 "2006-09-15T00:26:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 15, 2006, 10:55pm UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/4 "2006-09-15T22:55:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 16, 2006, 12:37am UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/5 "2006-09-16T00:37:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 15, 2006, 6:22pm UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/6 "2006-09-15T18:22:57Z")

</div>

On 9/14/06, Dan B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 16, 2006, 4:31am UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/7 "2006-09-16T04:31:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [September 16, 2006, 6:01am UTC](https://www.ruby-forum.com/t/not-finding-a-breakpoint-values-are-nil/68731/8 "2006-09-16T06:01:52Z")

</div>

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?
