From: Roelof Wobben Date: 2012-09-25T22:23:24+09:00 Subject: Re: inject problem --_39ba81f3-0c66-49cf-9671-c4f2012f398a_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello=2C Of course I have read all the other postings.I only try to unders= tand how all the solutions work and I understand that inject is not a good = solutionand I better can use each_with_object. Roelof > Date: Tue=2C 25 Sep 2012 22:14:43 +0900 > From: lists@ruby-forum.com > Subject: Re: inject problem > To: ruby-talk@ruby-lang.org >=20 > Roelof Wobben wrote in post #1077457: > > I have one question about the solution of Prasadhnc C >=20 > Haven't you read the other postings? :-( >=20 > "inject" is completely useless in your case=2C since you don't do what=20 > it's meant for: building a value by subsequently calling the block. You=20 > just pass the same object again and again. Yes=2C "inject" still works.=20 > But you basically circumvent the actual mechanism -- in which case=20 > "each_with_object" would be a better fit. >=20 > Or do you want to use "inject" no matter what? >=20 > --=20 > Posted via http://www.ruby-forum.com/. >=20 = --_39ba81f3-0c66-49cf-9671-c4f2012f398a_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello=2C
 =3B
Of course I have read all =3Bthe other posting= s.
I =3Bonly try to understand how all the solutions work and I unde= rstand that inject is not a =3Bgood solution
and =3BI better can= use each_with_object.
 =3B
Roelof

 =3B
>=3B Date: Tue=2C 25 Sep 2012 22:14:43 += 0900
>=3B From: lists@ruby-forum.com
>=3B Subject: Re: inject pro= blem
>=3B To: ruby-talk@ruby-lang.org
>=3B
>=3B Roelof Wobb= en wrote in post #1077457:
>=3B >=3B I have one question about the s= olution of Prasadhnc C
>=3B
>=3B Haven't you read the other post= ings? :-(
>=3B
>=3B "inject" is completely useless in your case= =2C since you don't do what
>=3B it's meant for: building a value by = subsequently calling the block. You
>=3B just pass the same object ag= ain and again. Yes=2C "inject" still works.
>=3B But you basically ci= rcumvent the actual mechanism -- in which case
>=3B "each_with_object= " would be a better fit.
>=3B
>=3B Or do you want to use "inject= " no matter what?
>=3B
>=3B --
>=3B Posted via http://www.= ruby-forum.com/.
>=3B
= --_39ba81f3-0c66-49cf-9671-c4f2012f398a_--