From: Tim Hunter Date: 2007-11-17T23:10:38+09:00 Subject: Re: Observe variable set and variable change saladin.mundi@gmx.de wrote: > Hey folks, > > is there any kind of Ruby / C function with which it is possible to see when a variable is set or changed? > > Something like: > > class x > > def y() > z = 42 > z = 100 > end > end > > So that a function takes care about setting the 42 and another for caring about changing the value of z to 100? > > thanks in advance > > sala > Let's try again... There's Observable: ~$ ri Observable ------------------------------------------------------ Class: Observable Implements the Observable design pattern as a mixin so that other objects can be notified of changes in state. See observer.rb for details and an example. ------------------------------------------------------------------------ Instance methods: add_observer, changed, changed?, count_observers, delete_observer, delete_observers, notify_observers ~$ -- RMagick: http://rmagick.rubyforge.org/