From: Chris Carter Date: 2007-03-03T01:29:42+09:00 Subject: Re: Newbie Question On 3/1/07, Dick wrote: > Hi, > > I am new to Ruby. This is the very first class I am writing and it > doesn't seem that Ruby is designed to handle what I thought should work. > Why doesn't the below work? > > class Song < ActiveRecord::Base > @@dcounts = [] > > def Song.count(difficulty, artistid) > @@dcounts[difficulty][artistid] > end > > def Song.count=(difficulty, artistid, val) > @@dcounts[difficulty] ||= {} > @@dcounts[difficulty][artistid] = val > end > end > > Song.count(1, 3547) = 10 > > test.rb:14: parse error, unexpected '=', expecting $ > Song.count(1,3547) = 10 > ^ > > -- > Posted via http://www.ruby-forum.com/. > > You could do something like: def Song.count=(*args) @@dcounts[args[0]] ||= {} @@dcounts[args[0]][args[1]] = args[2] end Song.count 1, 3547, 10 -- Chris Carter concentrationstudios.com brynmawrcs.com