[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>

Currently, ruby/spec is maintained mostly by individuals and enjoys the

13 messages 2016/12/13

[ruby-core:78694] [Ruby trunk Bug#13044][Rejected] ruby unless bug with plural conditions

From: nobu@...
Date: 2016-12-17 01:52:58 UTC
List: ruby-core #78694
Issue #13044 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Rejected

`unless a && b` equals to `if !(a && b)`.
See https://en.wikipedia.org/wiki/De_Morgan%27s_laws for more info.


----------------------------------------
Bug #13044: ruby unless bug with plural conditions
https://bugs.ruby-lang.org/issues/13044#change-62071

* Author: Imran Ashraf
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I am working on an app where I need to process various data-items based upon different ruby types. While setting up conditonal-checks, I discovered that "unless" fails to handle plural conditions.

Please consider the following example:

~~~ruby
class ThingA end
class ThingB end
class ThingC end

# obj = ThingA.new
# obj = ThingB.new
obj = ThingC.new

# puts 'yes it is a ThingC' unless obj.is_a?(ThingA) && obj.is_a?(ThingB) # BUG

# puts 'yes it is a ThingC' if !obj.is_a?(ThingA) && !obj.is_a?(ThingB) # this works ok

# works ok with singular condition
unless obj.is_a?(ThingA)
  unless obj.is_a?(ThingB)
    puts 'yes it is a ThingC'
  end
end
~~~


Thanks.

Regards,
Imran





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next