bad String blows up world using length method!!!!!!!!!

X

Xeno Campanoli

Yeah, I'm pissed. This kind of thing shouldn't happen.

You read in a file. It's empty. You get an empty file in what you'd think
was a string, so you take the length, and it blows up the world in other
parts of your program! You check to see if it's a string with an:

contentvariable.is_a?String

and sure enough, it thinks it's a String, but sure enough, when you go

if contentvariable.size then

it also blows up with that synonym. Sorry to be less than cordial here, but
I really would have liked this to work.

Sincerely, Xeno Campanoli, working with Ruby on the Job.
xc
 
J

James Edward Gray II

Yeah, I'm pissed. This kind of thing shouldn't happen.

You read in a file. It's empty. You get an empty file in what
you'd think
was a string, so you take the length, and it blows up the world in
other
parts of your program! You check to see if it's a string with an:

contentvariable.is_a?String

and sure enough, it thinks it's a String, but sure enough, when you go

if contentvariable.size then

it also blows up with that synonym. Sorry to be less than cordial
here, but
I really would have liked this to work.

Something is fishy here. Please provide an example of broken code...

James Edward Gray II
 
D

David A. Black

Hi --

Yeah, I'm pissed. This kind of thing shouldn't happen.

You read in a file. It's empty. You get an empty file in what you'd think
was a string, so you take the length, and it blows up the world in other
parts of your program! You check to see if it's a string with an:

contentvariable.is_a?String

and sure enough, it thinks it's a String, but sure enough, when you go

if contentvariable.size then

it also blows up with that synonym. Sorry to be less than cordial here, but
I really would have liked this to work.

Are you sure you didn't do:

def contentvariable.size
raise
end

somewhere? :)

Just kidding. As Jam[ei]s said, one would have to see a full (non-)
working example to comment.


David
 
A

Ara.T.Howard

Yeah, I'm pissed. This kind of thing shouldn't happen.

You read in a file. It's empty. You get an empty file in what you'd think
was a string, so you take the length, and it blows up the world in other
parts of your program! You check to see if it's a string with an:

contentvariable.is_a?String

and sure enough, it thinks it's a String, but sure enough, when you go

if contentvariable.size then

it also blows up with that synonym. Sorry to be less than cordial here, but
I really would have liked this to work.

can we see the actual code? how did you install ruby?

regards.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| anything that contradicts experience and logic should be abandoned.
| -- h.h. the 14th dalai lama
===============================================================================
 
X

Xeno Campanoli

Yeah, hey sorry for getting so uptight guys, but it was really crazy,
and I was missing a goal time for showing something to my boss.

I won't have time to put together something solid as an example until
tomorrow night, but I'll try to give you guys my version and all that.
The really crazy thing is I was taking a filesize too, and when I tried
to test it, which I parsef from a split of a text record line, it bombed
out there too. Now said record was written for the same file.

The behavior was the kind of thing you see in C when you're going out of
bounds with some memory. Is there some memory bounds debug thing I can
check for such a problem with?

Sincerely, Xeno
xc
 
E

Erik Veenstra

if contentvariable.size then

Apart from the problem you described, this code will always
resolve to true: zero is true, not false. You could use
"contentvariable.empty?" instead.

gegroet,
Erik V. - http://www.erikveen.dds.nl/
 
K

Kevin Ballard

Erik said:
Apart from the problem you described, this code will always
resolve to true: zero is true, not false. You could use
"contentvariable.empty?" instead.

I prefer the more sensible

unless contentvariable.zero?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top