From: Yunfeng Xu Date: 2011-09-30T16:49:17+09:00 Subject: Re: What does "exit_on_fail("initialize") { hook('preinit') { preinit } } " mean? --20cf307814faa0b80c04ae23dc6f Content-Type: text/plain; charset=UTF-8 Thank for Candler. I have gotten it. For other newbies like me, I suggest read the book "The Ruby Programming Language" that has many details about block grammar. On Thu, Sep 29, 2011 at 5:00 PM, Brian Candler wrote: > Yunfeng Xu wrote in post #1024181: > > I can't understand why "exit_on_fail("initialize") { hook('preinit') { > > preinit } } " can be part of a statement together. I looked through some > > ruby books, but found no answer. > > Read a section about 'blocks'. e.g. > http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_containers.html#S2 > > Here you're not passing a block to be iterated (called multiple times), > but something to be called later on. > > class Foo > def prepare(&blk) > puts "I got a block! I'm going to run it later" > @my_block = blk > end > def doit > @my_block.call > end > end > > f = Foo.new > f.prepare { puts "Goodbye cruel world" } > puts "OK it's stored" > f.doit > > -- > Posted via http://www.ruby-forum.com/. > > --20cf307814faa0b80c04ae23dc6f--