is there a better way to write { yield }

S

Stephan Wehner

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
 
J

Joel VanderWerf

Stephan said:
Is there a better way to write something like

def meth(a,b,c)
:
:
other_meth(d) { yield }
:
:
end

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top