--cvVnyQ+4j833TQvp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 03, 2011 at 03:58:41AM +0900, 7stud -- wrote: > > This all sounds great but I am a little confused > > with what you exactly mean by, "Feel free to swap out > > do . . . end with { . . . }." > > ruby actually has two syntaxes for blocks: > > 1) > > ['hello', 'world', 'goodbye'].each {|word| puts word.upcase} > > 2) > > ['hello', 'world', 'goodbye'].each do |word| > puts word.upcase > end > > The general practice is: use parentheses for one liners, and do-end for > multi line blocks. > > There is actually one slight difference in effect between the two > syntaxes, but it is not worth mentioning at this point. As I recall, the only difference is binding precedence -- and I think the braces bind more tightly(?), but I may have that backwards. It hasn't come up for me so far; I'll have to look it up to remind myself if it ever does come up. -- Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --cvVnyQ+4j833TQvp Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk2X1o0ACgkQ9mn/Pj01uKXNCgCgi+MGMRKu4cN/mD06+cLuNu03 vXAAn3K7KfogGwqNzE+kKTAAWEZM2bki w/ -----END PGP SIGNATURE----- --cvVnyQ+4j833TQvp--