From: Philipp Meier Date: 2002-10-17T01:31:54+09:00 Subject: Re: passing on a block --PuGuTyElPB9bOcsM Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 15, 2002 at 03:18:29AM +0900, John Tromp wrote: > I defined a Statespace class, which happens to encode states as integers > in a range 0...nstates. > I want to provide an iterator like >=20 > def each > nstates.times { |i| yield i } > end >=20 > or i could write it as >=20 > def each(&b) > nstates.times(&b) > end >=20 > Which is the better or more Ruby-esque way? > Any difference in efficiency? I would take the latter because of does not hard codes the arity of #times. -billy. --=20 Meisterbohne S=F6flinger Stra=DFe 100 Tel: +49-731-399 499-0 eL=F6sungen 89077 Ulm Fax: +49-731-399 499-9 --PuGuTyElPB9bOcsM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iD8DBQE9rZR3fBriNoqItSYRAguqAJ94OTjMS1A2P1eNJOto02dORQcu7gCgk5AO Cqaqo+EOI1uhFw2cpEJDMLE= =7Ghp -----END PGP SIGNATURE----- --PuGuTyElPB9bOcsM--