Hello --

On Sun, 4 Nov 2001, Bob Sidebotham wrote:

> I hadn't understood that section of Programming Ruby. I see now that the
> example from PR:
>
>   bStart = JukeboxButton.new("Start") { songList.start }
>
> is exactly the same (I think) as:
>
>   bStart = JukeboxButton.new("Start", proc { songList.start })
>
> but lets you write what (I'm assuming) is a less efficient call using
> the same syntax as the more efficient block-only.

The important thing to remember, though, is that you can associate a
non-argument block with any method call.  So if you send a block as a
regular argument, you can still also associate a block:

  def thing(a,b,c)
    puts yield c.call(a, b)
  end

  thing(1,2, proc { |x,y| x + y }) { |n| "result is #{n}" }

  # =>  result is 3


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav