Joel VanderWerf
3/20/2006 7:55:00 PM
Shea Martin wrote:
> I have a function:
>
> def worker( &p_block )
> ....
> p_block.call( my_data )
> ....
> end
>
> I have a wrapper function, that I would like to use to call 'worker'.
> But I would like the caller of 'wrapper' to be able to specify the block
> 'wrapper' will use. i.e.,
>
> def wrapper( &p_block )
> ....
> worker{ p_block }
> end
>
> I suspect that this is possible, but I can't seem to nail the syntax.
def wrapper
worker {yield}
end
It makes sense once you "wrap" your head around it ;)
(Also, you might want, if possible, to use yield in worker, as well.
It's more efficient.)
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407