Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Implanting a new method for a class
james_b
2/12/2006 8:57:00 PM
Jeppe Jakobsen wrote:
> ...
> I get a NoMethodError on sum. Can anybody tell me what I did wrong here?
> Thanks in advance :)
>
You've defined a class method (e.g. Array.sum)
You need to do this:
class Array
def sum
until (Array.empty?)
...
--
James Britt
http://www.ru...
- Ruby Help & Documentation
http://www.artima.c...
- The Journal By & For Rubyists
http://www.rub...
- The Ruby Store for Ruby Stuff
http://www.jame...
- Playing with Better Toys
http://www.30seco...
- Building Better Tools
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Implanting a new method for a class
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password