Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: code blocks and methods
DDENNISON
4/9/2007 1:28:00 PM
I like to think of code blocks as a visitor pattern or a callback function.
You are essentially passing in a chunk of code to a method to be executed
for each logical element of data.
James Edward Gray
II
<james@grayproduc To
tions.net> ruby-talk@ruby-lang.org (ruby-talk
ML)
04/09/2007 07:46 cc
AM
Subject
Re: code blocks and methods
Please respond to
ruby-talk@ruby-la
ng.org
On Apr 8, 2007, at 12:29 PM, botp wrote:
> On 4/9/07, andy <eps@mailinator.com> wrote:
>> I am familiar with c# and java, one thing I don't understand is the
>> difference between code blocks and methods, can anyone offer a better
>> explanation than the one on the site above ?
>
> to quote carlson et al, "a Ruby code block is a method that has no
> name." see
http://www.devarticles.com/c/a/Ruby-on-Rails/Co...
> and-Iteration/
> or the ruby cookbook.
I wrote about my take on code blocks for my blog a while back:
http://blog.grayproductions.net/articles/2006/01/05/code-as-a...
James Edward Gray II
This message and any attachments contain information from Union Pacific which may be confidential and/or privileged.
If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited by law. If you receive this message in error, please contact the sender immediately and delete the message and any attachments.
2 Answers
Rick DeNatale
4/9/2007 1:58:00 PM
0
On 4/9/07, DDENNISON@up.com <DDENNISON@up.com> wrote:
> I like to think of code blocks as a visitor pattern or a callback function.
> You are essentially passing in a chunk of code to a method to be executed
> for each logical element of data.
That's more a description of how they are used in iterator methods
rather than a general description of code blocks and the variety of
ways they can be used.
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denh...
John Joyce
4/9/2007 3:00:00 PM
0
Ruby blocks are generally far simpler than they seem at first.
On Apr 9, 2007, at 10:57 PM, Rick DeNatale wrote:
> On 4/9/07, DDENNISON@up.com <DDENNISON@up.com> wrote:
>> I like to think of code blocks as a visitor pattern or a callback
>> function.
>> You are essentially passing in a chunk of code to a method to be
>> executed
>> for each logical element of data.
>
> That's more a description of how they are used in iterator methods
> rather than a general description of code blocks and the variety of
> ways they can be used.
>
> --
> Rick DeNatale
>
> My blog on Ruby
>
http://talklikeaduck.denh...
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: code blocks and methods
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password