Mike Gold wrote: > funcs2 = [] > for j in 1..5 > funcs2 << lambda { j } > end > p funcs2.map { |f| f.call } # => [5, 5, 5, 5, 5] > > I prefer to make the new binding scope of a block visually obvious, > therefore I always use {}. do/end tricks me into thinking it belongs to > the same category as for/end or while/end or if/end, but it's quite > different (above). > > Also, I like one rule better than two rules. Curiously, Ruby departs with 40 years of Structural Programming tradition - the statement groups controlled by if-end, and their ilk, do _not_ introduce a new variable scope, while the statement groups inside true blocks _do_ introduce scoped variables. Furtherless, the region inside a block _might_ be someone else's scope! Rails's render :update do ... end does this to us. Principle of Most Surprise applies. So making dangerous things like blocks look ugly is a good way to help us respect them! -- Phlip