From: "Luca (Email)" Date: 2011-12-29T15:45:29+09:00 Subject: I: errors with respond_to? and inject -----Messaggio originale----- Da: Peter Lane [mailto:peter.c.r.lane@googlemail.com] Inviato: giovedì 1 dicembre 2011 13:04 A: ruby-talk ML Oggetto: Re: errors with respond_to? and inject Sébastien M. wrote in post #1034503: > Quick question though > > Why don(t u need the 'respond_to?' method We still have to check if > object has a price method in order to return nil if not. Or is there > something i missed? You need respond_to? if you may pass in a non-Item instance to be added to an Item (or rather, as this is Ruby, an instance which does not respond to the 'price' method). Myself, I would try not to do that, but that depends on the design of the rest of your program. -- Posted via http://www.ruby-forum.com/. -- Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f Sponsor: Conto Arancio al 4,20%. Soldi sempre disponibili, zero spese, aprilo in due minuti! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid920&d)-12