# Problem with example from pickax book

**URL:** <https://www.ruby-forum.com/t/problem-with-example-from-pickax-book/109346>\
**Category:** Ruby\
**Created:** [July 13, 2007, 4:52pm UTC](https://www.ruby-forum.com/t/problem-with-example-from-pickax-book/109346 "2007-07-13T16:52:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benemson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@benemson](https://www.ruby-forum.com/u/benemson)\
**Post date:** [July 13, 2007, 4:52pm UTC](https://www.ruby-forum.com/t/problem-with-example-from-pickax-book/109346/1 "2007-07-13T16:52:49Z")

</div>

Working through the Pickax Ruby programing book and cant get the  
following example ‘compile’:-

irb(main):040:0\* class SongList  
irb(main):041:1\> MAX\_TIME = 5_60 # 5 minutes  
irb(main):042:1\>  
irb(main):043:1_ def Songlist.is\_too\_long(song)  
irb(main):044:2\> return song.duration \> MAX\_TIME  
irb(main):045:2\> end  
irb(main):046:1\> end  
(irb):41: warning: already initialized constant MAX\_TIME  
NameError: uninitialized constant SongList::Songlist  
from (irb):43  
from :0

Any idea why?

Ben

---

<div class="post-metadata">

**Author:** ![benemson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@benemson](https://www.ruby-forum.com/u/benemson)\
**Post date:** [July 13, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/problem-with-example-from-pickax-book/109346/2 "2007-07-13T17:21:53Z")

</div>

Dear Ben,

> irb(main):040:0\* class SongList  
> irb(main):041:1\> MAX\_TIME = 5_60 # 5 minutes  
> irb(main):042:1\>  
> irb(main):043:1_ def Songlist.is\_too\_long(song)  
> ^^^^^^^^^

Just leave out the underlined “Songlist.”  
Best regards,

Axel

---

<div class="post-metadata">

**Author:** ![benemson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@benemson](https://www.ruby-forum.com/u/benemson)\
**Post date:** [July 13, 2007, 5:30pm UTC](https://www.ruby-forum.com/t/problem-with-example-from-pickax-book/109346/3 "2007-07-13T17:30:54Z")

</div>

On Jul 13, 4:51 pm, “Ben E.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (irb):41: warning: already initialized constant MAX\_TIME  
> NameError: uninitialized constant SongList::Songlist

Songlist needs to be SongList. Or just change it to “self”. 🙂

---

<div class="post-metadata">

**Author:** ![benemson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@benemson](https://www.ruby-forum.com/u/benemson)\
**Post date:** [July 13, 2007, 5:31pm UTC](https://www.ruby-forum.com/t/problem-with-example-from-pickax-book/109346/4 "2007-07-13T17:31:54Z")

</div>

On 13/07/07, Axel E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Dear Ben,
> 
> > irb(main):040:0\* class SongList  
> > irb(main):041:1\> MAX\_TIME = 5_60 # 5 minutes  
> > irb(main):042:1\>  
> > irb(main):043:1_ def Songlist.is\_too\_long(song)  
> > ^^^^^^^^^
> 
> Just leave out the underlined “Songlist.”

Its actually supposed to be a class method, but ive spotted the error.  
It should be SongList, not Songlist (the L needs to be upper case).

Ta,  
Ben
