From: sawadatsuyoshi@... Date: 2016-07-02T10:14:45+00:00 Subject: [ruby-core:76232] [Ruby trunk Feature#12515] Create "Boolean" superclass of TrueClass / FalseClass Issue #12515 has been updated by Tsuyoshi Sawada. Martin D��rst wrote: > Actually, because both `true` and `false` are singletons, `TrueClass` and `FalseClass` look like overkill; in Ruby's ducktyping world, most if not all things would work just as well with the necessary methods for `true` and `false` being defined directly as singleton methods on `true` and `false`. My understanding is that defining a singleton method on an object creates a singleton class. And in case of `true`, `false` or `nil`, the singleton classes are in fact the classes in question: ~~~ruby true.singleton_class # => TrueClass false.singleton_class # => FalseClass nil.singleton_class # => NilClass ~~~ so there is no way to get rid of these classes. And by the way for the `Boolean` class proposed in this thread, it surely is un-useful. ---------------------------------------- Feature #12515: Create "Boolean" superclass of TrueClass / FalseClass https://bugs.ruby-lang.org/issues/12515#change-59465 * Author: Loren Segal * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Since Ruby 2.4 is unifying Bignum/Fixnum into Integer (https://bugs.ruby-lang.org/issues/12005), it seems reasonable to do something similar for TrueClass / FalseClass, and create a proper Boolean hierarchy. The implementation would be fairly straightforward and should be back compat unless someone already has a "Boolean" class at toplevel out there. Given the compatibility implications of Integer, this Boolean proposal is even less intrusive. Sample implementation: ~~~ class Boolean < BasicObject; end class TrueClass < Boolean; end class FalseClass < Boolean; end ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: