From: "rits (First Last)" Date: 2013-12-17T03:19:01+09:00 Subject: [ruby-core:59144] [ruby-trunk - Bug #9251] ! operator has lower precedence than = in an assignment expression Issue #9251 has been updated by rits (First Last). mame (Yusuke Endoh) wrote: > I don't have the book, but I guess it is not wrong. > > Perhaps the book explains the precedence rules of *the expression*. But the left-hand side of = is not an expression. So there is nothing wrong in the book and implementation. > The book has a table of all operators grouped and sorted by precedence. ! has higher precedence than =. The rules of precedence are precisely for determining which operator binds tighter or has precedence in an expression. "!a = true" is an expression and according to ruby's rules of precedence should mean "(!a) = true" and thus an error. The current implementation violates the rules of precedence from the book. ---------------------------------------- Bug #9251: ! operator has lower precedence than = in an assignment expression https://bugs.ruby-lang.org/issues/9251#change-43706 Author: rits (First Last) Status: Feedback Priority: Low Assignee: Category: doc Target version: ruby -v: ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN irb(main):001:0> !a = 1 (irb):1: warning: found = in conditional, should be == => false irb(main):002:0> a => 1 ! is supposed to have higher precedence than =, so !a = 1 should be (!a) = 1, and thus an error, not !(a = 1) -- http://bugs.ruby-lang.org/