From: "Michael T. Richter" Date: 2008-05-03T22:25:06+09:00 Subject: Re: a ? b : c --=-6iIYKTZ6z7j/pcRYGqZM Content-Type: multipart/alternative; boundary="=-HPd1fIP2O91pEuwSVmpP" --=-HPd1fIP2O91pEuwSVmpP Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat, 2008-05-03 at 22:01 +0900, luka luka wrote: > Hi all! > please explain, what is it? what he is doing? > example: >=20 > x =3D 6 > y =3D x =3D=3D 5 ? 0 : 2 > puts y // prints 2 >=20 > or: >=20 > x =3D=3D 5 ? puts("one") : puts("two") # Prints two >=20 > thanks. irb(main):001:0> x =3D 6 =3D> 6 irb(main):002:0> y =3D x =3D=3D 5 ? 0 : 2 =3D> 2 irb(main):003:0> x =3D 6 =3D> 6 irb(main):004:0> y =3D if x =3D=3D 5 irb(main):005:1> 0 irb(main):006:1> else irb(main):007:1* 2 irb(main):008:1> end =3D> 2 irb(main):009:0>=20 Get it? --=20 Michael T. Richter (GoogleTalk: ttmrichter@gmail.com) If there's one thing that computers do well, it's to make the same mistake uncountable times at inhuman speed. (Peter Coffee) --=-HPd1fIP2O91pEuwSVmpP Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sat, 2008-05-03 at 22:01 +0900, luka luka wrote:
Hi all!
please explain, what is it? what he is doing?
example:

x =3D 6
y =3D x =3D=3D 5 ? 0 : 2
puts y // prints 2

or:

x =3D=3D 5 ? puts("one") : puts("two=
")  # Prints two

thanks.

irb(main):001:0> x =3D 6
=3D> 6
irb(main):002:0> y =3D x =3D=3D 5 ? 0 : 2
=3D> 2
irb(main):003:0> x =3D 6
=3D> 6
irb(main):004:0> y =3D if x =3D=3D 5
irb(main):005:1> 0
irb(main):006:1> else
irb(main):007:1* 2
irb(main):008:1> end
=3D> 2
irb(main):009:0> 

Get it?

--
Michael T. Richter <ttmri= chter@gmail.com> (GoogleTalk: ttmrichter@gmail.com)
If there's one thing that computers do well, it's to make the same mista= ke uncountable times at inhuman speed. (Peter Coffee)
--=-HPd1fIP2O91pEuwSVmpP-- --=-6iIYKTZ6z7j/pcRYGqZM Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIHGelLqyWkKVQ54QRAu5gAKCK/6dCwzIRrr2w5StX2Y7s1IdT4gCgkr1o EjD2P76rfIVEA5UjzlrOkjk= =vg4t -----END PGP SIGNATURE----- --=-6iIYKTZ6z7j/pcRYGqZM--