From: Chad Perrin Date: 2011-03-24T07:30:59+09:00 Subject: Re: Converting PHP to Ruby --JP+T4n/bALQSJXh8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 24, 2011 at 05:52:58AM +0900, Jack W. wrote: >=20 > And one more question, how do I make one line statements in Ruby? I=20 > would do like this in PHP. >=20 > $animal =3D "cat"; > print $animal=3D=3D"cat" ? "yes" : "no"; //Would print yes The same thing works in Ruby. You don't need the dollar signs unless you want to specify global scope, though, and you don't need semicolons unless you want to put the lines of code on the same text line. The term for what you're doing here is "ternary operator". By the way, in your code, you should really use longer variable names that describe their purpose. It not only helps you understand your own code later, but also helps others understand what you're doing when you ask for help. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --JP+T4n/bALQSJXh8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk2KcdMACgkQ9mn/Pj01uKXldQCgsUjWJJlF0pIQxRoMM4EUDBP1 j2UAoPO9SvUMJwQF9XlM76AdoCgAszcC =Z0yS -----END PGP SIGNATURE----- --JP+T4n/bALQSJXh8--