Is there a better way to write something like
def meth(a,b,c)
:
:
other_meth(d) { yield }
:
:
end
That { yield } has some redundancy.
Thanks
Stephan
Is there a better way to write something like
def meth(a,b,c)
:
:
other_meth(d) { yield }
:
:
end
That { yield } has some redundancy.
Thanks
Stephan
On May 20, 2008, at 4:58 PM, Stephan W. wrote:
That { yield } has some redundancy.
Thanks
Stephan
Posted via http://www.ruby-forum.com/.
def meth(*a, &b)
other_method(*a, &b)
end
Stephan W. wrote:
That { yield } has some redundancy.
That form has the advantage, IIUC, that no Proc object is created, so
it’s a little more efficient. (Search the archives for block versus
proc.) Also, Rdoc can pick up the yield (and its arg) automatically.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs