From: blondinet Date: 2008-01-13T02:54:58+09:00 Subject: Callable class with block Hi everyone, I would like to know why the following code does not work : ----- class A def A.[](*args,&block) result = self.new( *args ) if block yield result result.end end return result end def end() puts "end" end end A[] do |a| puts "a #{a.inspect}" end ----- When I want to execute this script, the interpreter outputs the following error : -- d:/DEV/XRVG/bug.rb:18: parse error, unexpected kDO, expecting $ A[] do |a| -- If I write "A.[] do |a|" instead of "A[] do |a|", it is OK and outputs: ---- a # end ---- Any idea ? Any help appreciated !! Thanks in advance.