Yield

I don't know if it is the right place to ask about it, but I'll try even if I am
egged:-)

we have

def calculate(first,second)

yield(first,second) if block_given?

end

def calculate(first, second, &block)

block.call(first, second) if block

end

def calculate(frist, second, &block)

block.yield(first, second) if block

end

Are examples 2,3 identical? Is yield method in context of explicit parameter
passing the same as call method?;

If they are the same, is one of them an alias?

I didn't find yield method in ruby-doc.org/core-2.3.0/Proc.html but it is working
on the ruby-2.3.0. Does it mean that this method will be removed further?

In ruby-doc.org/core-2.2.0/Proc.html I didn't find any difference between call
and yield, but also I din't find if any of them is an alias.

dade.

I don't know if it is the right place to ask about it, but I'll try even if I am
egged:-)

This is a general list about Ruby, so yes, this is the right place :slight_smile:

we have

def calculate(first,second)

yield(first,second) if block_given?

end

def calculate(first, second, &block)

block.call(first, second) if block

end

def calculate(frist, second, &block)

block.yield(first, second) if block

end

Are examples 2,3 identical? Is yield method in context of explicit parameter
passing the same as call method?;

It seems so based on reading the Init_Proc function proc.c of Ruby source.

If they are the same, is one of them an alias?

Not actually an alias, but they are defined to the same method;
so in practice, yes, they are the same.

I didn't find yield method in ruby-doc.org/core-2.3.0/Proc.html but it is working
on the ruby-2.3.0. Does it mean that this method will be removed further?

In ruby-doc.org/core-2.2.0/Proc.html I didn't find any difference between call
and yield, but also I din't find if any of them is an alias.

It looks like enabling an optimization in Ruby 2.3 broke
the way rdoc generates documentation. I will see about fixing it.

https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/proc.c?r1=52050&r2=52049&pathrev=52050&diff_format=l

But no, I don't think it will be removed.

···

dade <dimapg@rambler.ru> wrote:

Maybe there's a better fix, but I've proposed this:

···

Eric Wong <normalperson@yhbt.net> wrote:

dade <dimapg@rambler.ru> wrote:
> I didn't find yield method in ruby-doc.org/core-2.3.0/Proc.html but it is working
> on the ruby-2.3.0. Does it mean that this method will be removed further?

It looks like enabling an optimization in Ruby 2.3 broke
the way rdoc generates documentation. I will see about fixing it.

Thanks for your answer

dade.

  > > I didn't find yield method in ruby-doc.org/core-2.3.0/Proc.html but it is
  working
  > > on the ruby-2.3.0. Does it mean that this method will be removed further?
  >
  > It looks like enabling an optimization in Ruby 2.3 broke
  > the way rdoc generates documentation. I will see about fixing it.

  Maybe there's a better fix, but I've proposed this:
  https://bugs.ruby-lang.org/issues/12332

···

4/30/2016, 1:10:19 AM пользователь Eric Wong (normalperson@yhbt.net) написал:
  Eric Wong <normalperson@yhbt.net> wrote:
  > dade <dimapg@rambler.ru> wrote: