From: John W Higgins Date: 2013-03-09T15:36:06+09:00 Subject: Re: Ruby’s iterators and code blocks --20cf307f37f40d4fa804d7780e78 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable a =3D [1, 2, 3] a.each {|x| puts x + 1 } # today I would like to add one during my #each call a.each {|x| puts x + 2 } # oops changed my mind and would like to add two now Both call the #each method with a block that allows me to customized what I do with the exact same items. #each doesn't change but the result of the call does for each case. John On Fri, Mar 8, 2013 at 10:16 PM, Kumar R. wrote: > From one of the Ruby's resource I found the below statement: > > "Ruby=92s iterators and code blocks allow you to write and use methods > that are engineered to share their own functionality with their callers. > The method contains some logic and procedure, but when you call the > method,*** you supply additional code that fills out the logic and > individualizes the particular call you=92re making***. It=92s an elegant > feature with endless applications." > > But only the line within the *** I couldn't understand well. > > Can anyone help me to reach out to the fact that had been tried to > deliver by that line? > > -- > Posted via http://www.ruby-forum.com/. > --20cf307f37f40d4fa804d7780e78 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable a =3D [1, 2, 3]

a.each {|x| puts x + 1 } # today I would like to add= one during my #each call
a.each {|x| puts x + 2 } # oops changed my min= d and would like to add two now

Both call the #each method with a bl= ock that allows me to customized what I do with the exact same items. #each= doesn't change but the result of the call does for each case.

John

On Fri, Mar 8, 2013 at 10:16 PM,= Kumar R. <lists@ruby-forum.com> wrote:
From one of the Ruby's resource I found = the below statement:

"Ruby=92s iterators and code blocks allow you to write and use methods=
that are engineered to share their own functionality with their callers. The method contains some logic and procedure, but when you call the
method,*** you supply additional code that fills out the logic and
individualizes the particular call you=92re making***. It=92s an elegant feature with endless applications."

But only the line within the *** I couldn't understand well.

Can anyone help me to reach out to the fact that had been tried to
deliver by that line?

--
Posted via http://= www.ruby-forum.com/.

--20cf307f37f40d4fa804d7780e78--