From: Edward Faulkner Date: 2005-10-04T04:11:47+09:00 Subject: Re: [SOLUTION] Lisp Game (#49) --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 04, 2005 at 04:00:59AM +0900, Warren Brown wrote: > def describe_set(set) > set.inject("") {|s,o| s += "There is a ${o} here. "} > end You don't need the assignment. #inject automatically sets 's' to the previous value of the block: set.inject("") {|s,o| s + "There is a ${o} here. "} The assignment doesn't hurt anything, but it obscures what's really happening. For example, this would give the wrong answer: set.inject("") {|s,o| s += "There is a #{o} here. "; print "Looping\n"} regards, Ed --4Ckj6UjgE2iN1+kY Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFDQYICnhUz11p9MSARAsa5AJ9U75WRocEeGoqtXvKEQTivt+APwwCeNOvF DbhdwF1o1uhCtBRSTjUr9uc= =jDqW -----END PGP SIGNATURE----- --4Ckj6UjgE2iN1+kY--