james_b
2/5/2006 6:30:00 PM
jonT wrote:
> Hi,
>
> I'd like to be able to do the following:
>
> class Method; attr_accessor :foo; end
> def bar; "some_res"; end
> method(:bar).foo=1
>
> method(:bar).foo #= 1
>
> Of coures what i'd actually get is:
> method(:bar).foo #= nil
>
> because method(:bar) returns a new object each time.
A String, in your example. Do you want the string to respond to the
message 'foo=' ?
>
> Is it possible to bind properties to a method definition? If so, how?
>
What do you mean by "bind" and "properties"?
--
James Britt
"Programs must be written for people to read, and only incidentally
for machines to execute."
- H. Abelson and G. Sussman
(in "The Structure and Interpretation of Computer Programs)