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.
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
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.
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.
> > 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.