From 68b072bfbabdcd78b4d7980c15ab83163ecbacd3 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 15 Jan 2013 04:33:28 +0000 Subject: * doc/syntax/methods.rdoc (Method Names): Added method names including operator methods. * doc/syntax/methods.rdoc (Return Values): Added note that assignment methods ignore return values. * doc/syntax/precedence.rdoc: Added document describing precedence. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- doc/syntax/precedence.rdoc | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 doc/syntax/precedence.rdoc (limited to 'doc/syntax/precedence.rdoc') diff --git a/doc/syntax/precedence.rdoc b/doc/syntax/precedence.rdoc new file mode 100644 index 0000000000..515626c74f --- /dev/null +++ b/doc/syntax/precedence.rdoc @@ -0,0 +1,60 @@ += Precedence + +From highest to lowest, this is the precedence table for ruby. High precedence +operations happen before low precedence operations. + + !, ~, unary + + + ** + + unary - + + *, /, % + + +, - + + <<, >> + + & + + |, ^ + + >, >=, <, <= + + <=>, ==, ===, !=, =~, !~ + + && + + || + + .., ... + + ?, : + + modifier-rescue + + =, +=, -=, etc. + + defined? + + not + + or, and + + modifier-if, modifier-unless, modifier-while, modifier-until + + { } blocks + +Unary + and unary - are for +1, +-1 or -(a + b). + +Modifier-if, modifier-unless, etc. are for the modifier versions of those +keywords. For example, this is a modifier-unless expression: + + a += 1 unless a.zero? + +{ ... } blocks have priority below all listed operations, but +do ... end blocks have lower priority. + +All other words in the precedence table above are keywords. + -- cgit v1.2.3