From: Wyatt Greene Date: 2008-05-04T11:00:14+09:00 Subject: Re: a ? b : c On May 3, 10:42 am, Phillip Gawlowski wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > luka luka wrote: > > | And I have 1 question. > | What is: =~ > | What operator is it? > > I strongly suggest you avail yourself of a copy of Programming Ruby (and > The Ruby Way, too, if you can). > > The first edition of Programming Ruby is available free of charge online: > > http://www.ruby-doc.org/docs/ProgrammingRuby/ > > This will get you started on the basics of Ruby, and saves you the > annoyance of checking your inbox every two minutes. :) > > N.B.: Programming Ruby 1st Edition covers Ruby 1.6, but the basics > haven't really changed (i.e. operators, keywords, and the like). > > - -- > Phillip Gawlowski > Twitter: twitter.com/cynicalryan > Blog:http://justarubyist.blogspot.com > > Use the good features of a language; avoid the bad ones. > ~ - The Elements of Programming Style (Kernighan & Plaugher) > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (MingW32) > Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org > > iEYEARECAAYFAkgceecACgkQbtAgaoJTgL8kZQCgp7JyPWRnN8CIVTiIGcl3HPrb > tSAAoJ8RoWrSNioKwRANqG9ZJ6P4Mc5i > =iYQJ > -----END PGP SIGNATURE----- For what it's worth: The ?: operator is called the "conditional operator". It is the only ternary operator in Ruby (meaning the only operator that has three operands). The =~ is called the "pattern-matching operator". It is related to the !~ operator, which returns the boolean opposite of the =~ operator. If you want a good, solid reference book in Ruby, I would recommend "The Ruby Programming Language" by David Flanagan and Yukihiro Matsumoto. It might not be the best first book on Ruby, but in my opinion it is the most complete reference book available about the Ruby language.