From: Rick DeNatale Date: 2009-05-16T04:10:26+09:00 Subject: Re: obj.attr(qualifier) = value -- possible? On Fri, May 15, 2009 at 3:00 PM, Michael Schuerig wrote: > > I want to write a method that can be called like this > >  obj.attr(qualifier) = value > > So far, I don't see how to achieve this. I've tried > > class C >  def attr=(qualifier, value) >    ... >  end > end > > as well as > > class D >  def attr(qualifier) >    Proxy.new(self, qualifier) >  end >  class Proxy >    def =(value) >      ... >    end >  end > end > > Neither is valid Ruby, apparently. Is there another, working way? I don't think you can get the calling syntax you want. The best you can do I think is obj.attr = qualifier, value -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale