From: Morton Goldberg Date: 2007-10-11T11:27:04+09:00 Subject: Re: |how do you know when to put a variable between pipes?| On Oct 10, 2007, at 9:35 PM, A Love of Surf wrote: > Hi i am at about page fifty in the pickaxe book, and i have a > question. I see a lot of examples of a block that starts with | > SomeVar| and I dont really understand how you know when you can do > this or what the value will be that is passed to the variable. What > is the name of this construct or the var that goes in pipes? Thank > you :) In the PDF version of Pickaxe, this is explained beginning on p. 47 (p.50 in the printed text). Read the explanation that goes along with the fib_up_to example. More info can be found in Chapter 22 under the heading: Blocks, Closures, and Proc Objects. A quick and dirty explanation is the the vertical bars at the beginning of a block delimit the block's formal arguments. When the block is evaluated by a yield expression, the actually arguments passed to the yield will be assigned to the formal arguments in a manner similar to a function call. Just as you can't call a function without knowing what arguments it takes, you must know what arguments a method accepting a block passes to the block in order to write a block for that method. It is a matter of documentation. Regards, Morton