------ art_998_11736197.1210250130967 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Yes, Jesus - Thank you! It is, as I said earlier, embarrassing! BTW Jesus, on what country are you located? I'm in Brooklyn New York, USA. On Thu, May 8, 2008 at 8:33 AM, Victor Reyes <victor.reyes / gmail.com> wrote: > Embarrassing!!!!!!!!! To say the least! > Even when I copy, I don't copy right! > > Thank you Jano! > > > On Thu, May 8, 2008 at 8:22 AM, Jano Svitok <jan.svitok / gmail.com> wrote: > >> On Thu, May 8, 2008 at 2:09 PM, Victor Reyes <victor.reyes / gmail.com> >> wrote: >> > I lifted the following code from The Ruby way and tried to use it. >> > It does not output anything. >> > Do anyone knows why? >> > >> > Thank you >> > >> > Victor >> > >> > ############################## >> > # This code adds a count method to the Array class >> > # This code was lifted from: >> > # The Ruby Way >> > # Second Edition >> > # By: Hal Fulton >> > # Page: 270 >> > ############################## >> > class Array >> > def count >> > k sh.new(0) >> >> - self.each{|x| k[x]+1 } >> + self.each{|x| k[x]+} >> >> # notice the ign, you have not stored the result anywhere. >> >> > k >> > end >> > end >> > >> > >> > >> > @aa >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789], >> > >> > >> [123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789] >> > ] >> > >> > @ga >> > [0,0,0,0,1,9,0,4,0], >> > [0,0,4,8,0,0,6,0,0], >> > [7,5,0,0,0,0,0,0,2], >> > [0,9,0,1,0,2,0,0,4], >> > [0,0,0,0,0,3,0,0,0], >> > [5,0,0,4,0,6,0,3,0], >> > [8,0,0,0,0,0,0,7,3], >> > [0,0,6,0,0,8,4,0,0], >> > [0,1,0,2,9,0,0,0,0] >> > ] >> > >> > >> > # Test the count method: >> > >> > f ga[0].count >> > puts "f {f}" # The output here was: f >> > >> > f aa.count >> > puts "f {f}" # The output here was: f >> > >> >> > ------ art_998_11736197.1210250130967--