Re: Iterator Syntax
by Mathieu Bouchard other posts by this author
May 8 2002 3:57AM messages near this date
Re: Iterator Syntax
|
Re: Iterator Syntax
On Wed, 8 May 2002, Buggs wrote:
> On Tuesday 07 May 2002 16:24, Glen Starchman wrote:
> > On Tuesday 07 May 2002 02:47 am, Donal K. Fellows wrote:
> > "hello".each(3) { |x| print ("chars=%s", x)
> what about
> "hello".each(3)->x {print ("chars=%s", x)}
> if you still have "->" spare
> think
> x <-"hello".each(3) {print ("chars=%s", x)}
> is funny
putting the block parameters at the beginning of the block syntax like
{|x| ... } is well-justified: those parameters belong to the block, not to
the call. This is why the same kind of syntax was chosen in languages like
Smalltalk, Self, and Ruby.
The params belong to the block because it makes it easier to pass the
blocks around from call to call, or store them in variables.
________________________________________________________________
Mathieu Bouchard http://hostname.2y.net/~matju
Thread:
Glen Starchman
Donal K. Fellows
Glen Starchman
Pixel
Glen Starchman
Buggs
Mathieu Bouchard
Buggs
Mathieu Bouchard
Glen Starchman
|