Hi --

On Sat, 1 Dec 2007, Paul Private wrote:

> dear
> with the below mentioned script I would like to produce first all of the
> Java courses and then the Ruby ones.
> however I can't seem to get it to work
> I know I can use the partition method but I'm not able to get it to
> work.
> can you please help me out here
>
>
>
> require "collecties/cursus"
> class Cursus_applic
>  cursussen = [Cursus.new('Ruby - 1','Jan', 18.15, 10),
>  Cursus.new('Ruby - 2','Piet', 18.15, 8),
>  Cursus.new('Java - 1','Els', 14, 15),
>  Cursus.new('Java - 2','Jan', 14, 10),
>  Cursus.new('Java - 3','Piet', 18.15, 8)
>  ]
>
>  puts '5. First all Java courses then followed by the others: '
>  cursus_java = cursussen.partition {|cursus|cursus_java?(true)}

You're using a non-existent method, "cursus_java?" You probably want
to do:

   java, non_java = cursussen.partition {|cursus| cursus.naam?("Java") }

or something along those lines.

>  puts '6. Alle cursussen gesorteerd op cursus naam: '
>  puts '7. Alle cursussen voorafgegaan met de index: '
>
> end
> and the cursus.rb is mentioned here below
> class Cursus
>  attr :naam, false
>  attr_reader :docent
>  attr :tijdstip, false
>  attr_reader :aantal_cursisten

I believe that attr + false is the same as attr_reader -- except more
cryptic :-) It's best to stick to:

   attr_reader
   attr_writer
   attr_accessor

since the true/false parameter is not self-explanatory.


David

-- 
Upcoming training by David A. Black/Ruby Power and Light, LLC:
    * Intro to Rails, London, UK, December 3-6 (by Skills Matter)
See http://www.rubypal.com for details and 2008 announcements!