From: "J. Merrill" Date: 2005-11-19T01:43:04+09:00 Subject: Re: Block Syntax Error zhimin.wen wrote: > ===>8======================= > def func *args,&blk > puts *args > instance_eval &blk > end > > func("a str") {puts "blk"} #OK > func "a str" do puts "blk" end #OK > > func "a str" {puts "blk"} #Sytax Error!? > ===>8======================= > > The last call give a syntax error, which part confuse ruby? My opinion is that you should _want_ to put a comma before the {puts "blk"} to make it clear that you are passing a block parameter to func, rather than to "a str". Suppose the line were func foo {puts "blk"} where foo is a method -- in that case, the block is being passed to foo (and the result of foo is being passed to func), and if you're passing the block to func you'd write func foo, {puts "blk"} There are disadvantages to many attempts to reduce keystrokes, IMO. -- Posted via http://www.ruby-forum.com/.