From: Dossy Date: 2002-07-17T02:00:31+09:00 Subject: Re: TkText no -textvariable workaround? On 2002.07.17, Tom Sawyer wrote: > actually, Dossy, your post was a bit helpful. what i'm after also sort > of relates to the observer pattern. but in attempting to get ruby to > help me out with this i've stumbled upon an interesting question in its > own right (IMHO): > > in this simple example: > > a = 1 > > who is the receiver and what is the method? ...*long pause*... Speaking academically, the receiver is object a, the method is =(x). Ruby may have optimized some of this away, but it's essentially the idea. Sadly, you can't do this: irb(main):011:0> class Object irb(main):012:1> def =(x) irb(main):013:2> puts "You just set me to #{x}!" irb(main):014:2> end irb(main):015:1> end SyntaxError: compile error (irb):12: parse error def =(x) ^ (irb):15: parse error from (irb):15 Since I'm dumb, there's probably a really good reason for this but I can't think of it -- I just ate a ham and provolone sandwich. > i wondered this b/c i had the bright idea that i'd just modify the > Object class with an obverser pattern of sorts, to solve my problem, > but, well obviously that didn't go as planned and hence this question. Look at Test::Unit -- Nathaniel has nicely implemented the Observer pattern in Ruby. -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)