Thanks, Michael

Alan

"michael libby" <x / ichimunki.com> wrote in message
news:200210292004.31296.x / ichimunki.com...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Tuesday 29 October 2002 19:36, Alan (Ursus Major) wrote:
> > class Callback
> >
> >  def initialize (v, &m)
> >   @cb = m          #store a callback method
> >   @v = v            #store an argument to pass the method
> >  end
> >
> >  def exe
> >   #  @cb(@v)            #execute the stored method (not this way!)
>
> @cb.call(@v) #invokes method stored in @cb with @v as argument
>
> >   p "called exe, value = #{@v}"      #stored the value, and
> >   p "stored method =  #{@cb}"      #maybe the proc?
> >  end
> > end
> >
> > x = Callback.new("a value", &proc{|v| p v})
>
> x = Callback.new("a value"){|v| p v}   #much prettier, imho
>
> > x.exe
>
> Hope this helps.
>
>  -michael
>
> <signature>
>   <name>Michael C. Libby</name>
>   <email>x / ichimunki.com</email>
>   <web-site>http://www.ichimunki.com/</web-site>
>   <public-key>http://www.ichimunki.com/public_key.txt</public-key>
> </signature>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
>
> iD8DBQE9vz4t4ClW9KMwqnMRAinlAJ4rCuI7h5CX0+R6pXuC9qYp43N28gCfeX3a
> 7Hi9yK/+7XvHtdRiuV7Rp9c=
> =NuZX
> -----END PGP SIGNATURE-----
>
>