Ruby/Language Basics/Operators
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:59, 13 сентября 2010
chain statements together.
puts a = b = c = 0 p [ 3, 1, 7, 0 ].sort.reverse
Ruby Operators
Operator Description [ ] Array reference [ ]= Array element set ** Exponentiation ! Not ~ Complement + Unary plus - Minus * Multiply / Divide % Modulo + Plus - Minus >> Right shift << Left shift & Bitwise And ^ Bitwise exclusive Or (Xor) | Regular Or Comparison operators: <= Less than or equal to < Less than > Greater than >= Greater than or equal to Equality and pattern match operators: <=> Less than, equal to, greater than == Equal to === Tests equality in a when clause of a case statement != Not equal to =~ Regular expression pattern match && Logical And || Logical Or .. Inclusive range ... Exclusive range ? Ternary if : Else Assignment = Normal assign %= Modulus and assign /= Divide and assign -= Subtract and assign += Add and assign *= Multiply and assign **= Exponent and assign defined? True if symbol defined not Logical negation and Logical composition or