From: matz@... (Yukihiro Matsumoto) Date: 2002-03-14T23:18:51+09:00 Subject: Re: how do i: add_observer( { small bit of code } ) Hi, In message "Re: how do i: add_observer( { small bit of code } )" on 02/03/14, mrp@cre.canon.co.uk writes: |more context required from me! i'm using the observer mixin. putting |update() methods in observers is fine for 'normal' code, but when |writing unit tests etc. i want to use small bits of code like: | x.add_observer({ count += 1 }) | |up until now i've used a small Wrapper class (brief desc above). i'm now |wondering if there's a better way of doing this. any ideas? I guess a wrapper is the best solution, or you can define a "functional wrapper" like this: def proc_observer(&block) def block.update(*args) block.call(*args) end block end then x.add_observer(proc_observer{count += 1}) matz.