help me condence my code?

J

Jeremy Woertink

Simon said:
putting it into phrase-test.rb and running it that way I get:

ph-test.rb:3: undefined method `delete_at' for nil:NilClass
(NoMethodError)
from ph-test.rb:10:in `each_with_index'
from ph-test.rb:1:in `each'
from ph-test.rb:1:in `each_with_index'
from ph-test.rb:1

and relatedly, going through step by step I get:

023:0> end.delete_at(-1)
SyntaxError: compile error
(irb):23: syntax error, unexpected kEND
end.delete_at(-1)

I've never seen tacking things onto end before! is this possible?

hmm, well I guess that means that the delete_at(-1) isn't being called
on an array, so the return value of that isn't what I expected. But, to
answer the question it is possible to tack things on the end like that.
Take that delete_at(-1) off then run it and call f.class, it probably
says NilClass, but in the case it says Array, then I don't know back to
the books for me :)


~Jeremy
 
L

Logan Capaldo

eek. I've never written a unit test before. that's all incredibly
murky territory.. not only am I new to ruby, but new to programming in
general. I'll get around to it someday, I think. it just seems scary.
:)

Hah! Writing code that actually _does_ stuff doesn't seem scary to
you, but writing tests, that don't even need to do anything but make
sure you code does the right thing, (and you don't even have to write
the code first), is the scary, murky seeming thing? Writing code
without tests is murky. Writing code without tests is scary. Tests are
your friends.
 

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

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,005
Latest member
ChasityFan

Latest Threads

Top