From: "David A. Black" Date: 2008-04-30T23:07:44+09:00 Subject: Re: How to create "def method(item)= (value)" ? --1926193751-159575188-1209564463=:10890 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-159575188-1209564463=:10890" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-159575188-1209564463=:10890 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Wed, 30 Apr 2008, I=C3=B1aki Baz Castillo wrote: > 2008/4/30, David A. Black : > >> object =3D Object.new >> class << object >> attr_accessor :params >> end >> object.params =3D {} >> >> def object.[]=3D(key,value) >> @params[key] =3D value >> end >> >> object[1] =3D 2 >> >> p object.params # { 1 =3D> 2 } > > > Oh, that seems really interesting, but unfortunatelly I can't > unerstand at all what yuo do there. > Specially I don't understand the meaning of first two lines: > > object =3D Object.new > class << object > > What does that "class" mean?? http://www.wobblini.net/singletons.html David --=20 Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates! --1926193751-159575188-1209564463=:10890-- --1926193751-159575188-1209564463=:10890--