From: Chad Perrin Date: 2011-07-28T03:53:28+09:00 Subject: Re: How do we read this line of code? --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 28, 2011 at 03:24:08AM +0900, SW Engineer wrote: > If we have the following line of Ruby code: >=20 > @x.each do |x| >=20 > - What does |x| represent here? It's an argument supplied to the block that follows. In this case, the argument is an element of @x passed to the block. > - How do we read the line (i.e; in English)? I'd probably read it as something like: For EACH element X of INSTANCE VARIABLE X, DO . . . =2E . . if I was trying to make it read as smoothly as possible in English without giving much in the way of specific clues about Ruby syntax, sticking to the semantics of it. Note that I emphasized syntactic elements that actually appear in the code in my example by capitalizing all the letters in each of these elements. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --J/dobhs11T7y2rNN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk4wWqsACgkQ9mn/Pj01uKUTgwCgjadj8afuRm8MsqmmKvSlVef0 O1wAoMeqztXUz891TRjMXDmBssFQFcK7 =Cf5w -----END PGP SIGNATURE----- --J/dobhs11T7y2rNN--