Project

General

Profile

Actions

Feature #14224

closed

Boolean class

Added by sobrinho (Gabriel Sobrinho) almost 7 years ago. Updated almost 3 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:84408]

Description

Suggestion: TrueClass and FalseClass inheriting from Boolean (new superclass).

This would make true/false checking easier, like:

unless value.is_a?(Boolean)
  raise "Non-boolean value"
end

Currently we have to check for both classes:

unless value.is_a?(FalseClass) or value.is_a?(TrueClass)
  raise "Non-boolean value"
end

In high-level APIs this would be beneficial, for example in RSpec:

expect(value).to be_a Boolean

Currently, we have to check like this:

expect([TrueClass, FalseClass]).to include value.class

Or another similar workaround.

I would like to provide a patch if this is acceptable.


Related issues 2 (1 open1 closed)

Related to Ruby master - Feature #20756: Introduce Boolean classRejectedActions
Related to Ruby master - Feature #20882: Provide Boolean(...)OpenActions

Updated by jeremyevans0 (Jeremy Evans) almost 7 years ago

  • Status changed from Open to Rejected

This was already discussed and rejected in #12515.

Actions #2

Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago

  • Project changed from 14 to Ruby master
Actions #3

Updated by byroot (Jean Boussier) 2 months ago

Actions #4

Updated by hsbt (Hiroshi SHIBATA) 9 days ago

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0