From: chris@... Date: 2019-04-15T11:32:30+00:00 Subject: [ruby-core:92294] [Ruby trunk Bug#15768] "and", &&, boolean issue, different ruby versions, confusing Issue #15768 has been updated by chrisseaton (Chris Seaton). I think there's two things confusing you here. Firstly, `v1 = true and false` is `((v1 = true) and false)`, while `v2 = true && false` is `(v2 = (true && false))`. `--dump=parser` will tell you this. Secondly, when you do `v1 = true and false` in IRB and it prints the result you are really doing `p (v1 = true and false)`, not `v1 = true and false; p v1` which is what I think you're imagining. I think those two things explain all the differences you're seeing, and my understanding is all that behaviour is as per design, documentation, and specs. I do see why it could be confusing though. ---------------------------------------- Bug #15768: "and", &&, boolean issue, different ruby versions, confusing https://bugs.ruby-lang.org/issues/15768#change-77628 * Author: daBee (da Bee) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin15] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Just caught this: ``` ruby # version 2.5.1, Mac OS v1 = true and false # => IRB: true p v1 # => app.rb: true, IRB: false v2 = true && false # => IRB: false p v2 # => app.rb: false, IRB: false puts 1 > -1 && 257 < 256 # => app.rb: false, IRB: false ``` ## IRB Mac OS 2.6.2 ``` ruby >> v1 = true and false => false >> v2 = true && false => false >> puts v1 true => nil >> puts v2 false => nil ``` I might be missing something, but I think there's an issue here, on both versions 2.5.1 and 2.6.2. -- https://bugs.ruby-lang.org/ Unsubscribe: