Hi,

Am Freitag, 28. Sep 2007, 17:20:40 +0900 schrieb Tom Metge:
> On 9/28/07 2:13 AM, "Daniel Talsky" <danieltalsky / gmail.com> wrote:
> 
> > 10.times do
> >   collection_of_objects << MyObject.create
> > end
> > 
> > But this doesn't:
> > 
> > 10.times do { collection_of_objects << MyObject.create }
> 
> Take the "do" out of the statement when passing a block in {}:
> 
> 10.times {collection_of_objects << MyObject.create}

Yet another opportunity to mention that {} has higer
precedence than do..end.

    def f
      puts "((("
      yield if block_given?
      puts ")))"
    end
    def g x
      puts "[[[#{x}|"
      yield if block_given?
      puts "]]]"
    end

  > g f { puts "x" }
  (((
  x
  )))
  [[[|
  ]]]
  > g f do puts "x" end
  (((
  )))
  [[[|
  x
  ]]]


Not a very intuitive example I admit.

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de