--------------040101050007000100010403
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Thanks for responding

I get the same error." undefined method push for append"
Is push a predefined function in the array function library?
a  rray.new
a[0]  
a[2] 
a.push(2)
[ 1,nil,2,2]
I know I must have the libraries somewhere on my system as I looked ahead
in the book and fooled around with the require Tk commands.
A locate ruby command at the shell prompt reveals little.


re-v

Daniel Carrera wrote:

>I can't see anything wrong.  Does this work?
>
>list.append(Song.new('title1', 'artist1', 1))
>
>It would help me if you wrote a sample program that caused the error and 
>sent it to me.  I can then try to figure out what's going on.
>
>
>On Wed, Feb 19, 2003 at 09:31:21AM +0900, reavey wrote:
>  
>
>>hi
>>I get an error
>>"NameError: undefined method 'push' for nil from append"
>>as I'm working thru the Prag prog ruby book.
>>"""We'll start our class with a basic initialize method, which creates 
>>the Array we'll use to hold our songs and store a reference to it in the 
>>instance variable @songs
>>
>>class SongList
>>   def initialize
>>     @songs  rray.new
>>   end
>>end
>>
>>The SongList#append method adds the given song to the end of teh @songs 
>>array. It also
>>returns self, a reference to the current SongList object. This is a 
>>useful convention, as it allows us to chain together multiple calls to 
>>appand...
>>
>>class Songlist
>>      def append(aSong)
>>       @songs.push(aSong)
>>       self
>>   end
>>end
>>
>>list  ongList.new
>>list.
>>   append(Song.new('title1', 'artist1', 1)).
>>   append(Song.new('title2', 'artist2', 2))      """
>>
>>reports the error.
>>I've worked through all the example code and have been very impressed. 
>>It is
>>very instructive and is the only book I've seen that tries to teach 
>>using a real model.
>>
>>I'm writting all the code in irb.  Also, a test like
>>cSong  ong.new('title', 'artist', 245)
>>works fine.
>>
>>
>>
>>
>>    
>>
>
>  
>


--------------040101050007000100010403
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
Thanks for responding<br>
<br>
I get the same error." undefined method push for append"<br>
Is push a predefined function in the array function library? <br>
a  rray.new<br>
a[0]  <br>
a[2] <br>
a.push(2)<br>
[ 1,nil,2,2]<br>
I know I must have the libraries somewhere on my system as I looked ahead<br>
in the book and fooled around with the require Tk commands.<br>
A locate ruby command at the shell prompt reveals little.<br>
<br>
<br>
re-v<br>
<br>
Daniel Carrera wrote:<br>
<blockquote type
ite" citeid20030219010020.GB1457 / math.umd.edu"> <pre wrap>I can't see anything wrong. Does this work? list.append(Song.new('title1', 'artist1', 1)) It would help me if you wrote a sample program that caused the error and sent it to me. I can then try to figure out what's going on. On Wed, Feb 19, 2003 at 09:31:21AM +0900, reavey wrote: </pre> <blockquote type
ite"> <pre wrap>hi I get an error "NameError: undefined method 'push' for nil from append" as I'm working thru the Prag prog ruby book. """We'll start our class with a basic initialize method, which creates the Array we'll use to hold our songs and store a reference to it in the instance variable @songs class SongList def initialize @songs rray.new end end The SongList#append method adds the given song to the end of teh @songs array. It also returns self, a reference to the current SongList object. This is a useful convention, as it allows us to chain together multiple calls to appand... class Songlist def append(aSong) @songs.push(aSong) self end end list ongList.new list. append(Song.new('title1', 'artist1', 1)). append(Song.new('title2', 'artist2', 2)) """ reports the error. I've worked through all the example code and have been very impressed. It is very instructive and is the only book I've seen that tries to teach using a real model. I'm writting all the code in irb. Also, a test like cSong ong.new('title', 'artist', 245) works fine. </pre> </blockquote> <pre wrap><!----> </pre> </blockquote> <br> </body> </html> --------------040101050007000100010403--