James Gray
7/9/2007 1:30:00 PM
On Jul 9, 2007, at 8:27 AM, John Joyce wrote:
>
> On Jul 9, 2007, at 7:06 AM, Yukihiro Matsumoto wrote:
>
>> Hi,
>>
>> In message "Re: Yield should be renamed call_block"
>> on Mon, 9 Jul 2007 19:17:13 +0900, dblack@wobblini.net writes:
>>
>> |> I am not going to rename it. But in far future (3.0? maybe), the
>> |> keyword will be removed from the language, and you will access
>> blocks
>> |> via block arguments of methods.
>> |
>> |I'm curious what the rationale is for that. Also, will the block
>> |syntax be removed, in favor of Proc arguments?
>>
>> The code
>>
>> def ntimes(n)
>> n.times do
>> yield
>> end
>> end
>>
>> would go like this
>>
>> def ntimes(n, &b)
>> n.times do
>> b.yield
>> end
>> end
>>
>>
> the '&' sigil is kind of scary. Reminds me of C. I'd be
> disappointed to see Ruby get more sigils.
That's nothing new for Ruby. It works today. It's also needed.
Without it, it wouldn't be possible to save a block into a variable
for later use.
James Edward Gray II