From: Paul Private Date: 2007-12-02T15:20:04+09:00 Subject: Re: question about iterator THanks Jordan this was exactly what I was looking for Paul Jordan Callicoat wrote: > On Dec 1, 2:05 pm, Paul Private wrote: >> class Cursus_applic >> puts Java, other >> >> >> zoo.each { |a| puts a.name } >> > In defining your class it is easy to override any inherited method, >> > and generally a lot less work to inherit than to create everything >> > from nothing. >> >> > Is het voor en hogeschool in het Nederlands? Polytechnische school? >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > Like others have mentioned, you're calling <=> on an instance of class > Cursus, but haven't defined it for that class. I think what you mean > is... > > cursussen.sort { |a, b| a.to_s <=> b.to_s } > > ...Cursus#to_s is only implicitly called when a string object is > required (like for puts, or when it is coerced by "string +", &c). > Otherwise you have to explicitly call it yourself. > > Regards, > Jordan -- Posted via http://www.ruby-forum.com/.