From: Gavin Sinclair Date: 2002-12-01T23:07:25+09:00 Subject: [FAQ] What do some of Ruby's symbols mean? This could do with some community input before going to the FAQ. The format will be different but I just wanted to bang out some content. I haven't even checked if there is a question like this. Can anyone think of a question title that does't create confusion with :name symbols? --- Q: What do some of Ruby's symbols mean? A: This question is about non-aplhanumeric characters in Ruby code, not about *symbols* like :name. For those, see [appropriate link]. Actual explanations of the concepts behind them is beyond the scope of this answer. <= < != == > >> Relational operators, as per most other computer languages. Are often redefined for use with various classes. + - * / % Common arithmetic operators. Some are defined also for String, Array and others. === Case comparison operator. Used to select branches in case statements. < Class inheritance, as in class Car < Vehicle end << Funny class inheritance; see [appropriate link] for a rationale. Also commonly used as a method for appending (e.g. Array and String). .. ... Range definers, as in 0...10 and "a".."z" : Symbol definer, as in :name, where :name.to_s == "name". See [a/l]. See next item also. ?: Ternary decision operator, as in C. For example: iq = (position == MANAGER) ? LOW : HIGH {} => Hash definition, as in numstr = { 1 => "one", 2 => "two", ... } [] Array definition, as in ndays = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] %w[] String-Array converter, as in dayabbrev = %w[Sun Mon Tue Wed Thu Fri Sat] dayabbrev == ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] // Regular expression definition, as in date_re = /(\d\d\d\d)-(\d\d)-(\d\d)/ y, m, d = date_re.match("2002-12-01")[1..3] ?! Suffixes for methods (optional, of course). In general: method! changes the object (e.g. String.gsub!) method? returns boolean (e.g. Array.empty?)