From: Tachikoma Date: 2008-07-16T16:15:32+09:00 Subject: Re: New to Ruby. Specific syntax question. On Jul 16, 12:20 pm, Cole Mister wrote: > I'm reading through the PickAxe book right now.  I'm new to programming, > and more specifically, Ruby. > > Right now I'm looking at a line that says this: > fib_up_to(1000) {|f| print f, ""} > > I'm curious about the parts of this statement. > > I know that "fib_up_to(1000)" passes 1000 into this specific method. > > The thing that gets me confused is the block statement (right > terminology?).  What's the "|f|"?  I know "print f" says to print this > variable.  Then, what're the quotes for? > > Is a variable "f" created in this block, then told to print, and more > specifically, told to print into the parentheses? > > I'm new, so sorry if this is a hang-up.  I just want to understand. > > Thank you. > -- > Posted viahttp://www.ruby-forum.com/. it's not a variable create in this block, but a variable passed into the block take an example: def fib_up_to(max) .... yield t ... end fib_up_to(1000) {|f| print f} the f in block is the t in each step