Sha256: bf1d0766cdd24f4e63b59af9bbdd9b714b7088e2a1aa3e48a0bb7107fb8cc8d9
Contents?: true
Size: 602 Bytes
Versions: 21
Compression:
Stored size: 602 Bytes
Contents
# typed: strict # frozen_string_literal: true class Class extend T::Sig # Returns an array with all classes that are < than its receiver. # # class C; end # C.descendants # => [] # # class B < C; end # C.descendants # => [B] # # class A < B; end # C.descendants # => [B, A] # # class D < C; end # C.descendants # => [B, A, D] sig { returns(T::Array[Class]) } def descendants result = ObjectSpace.each_object(singleton_class).reject do |k| T.cast(k, Module).singleton_class? || k == self end T.cast(result, T::Array[Class]) end end
Version data entries
21 entries across 21 versions & 1 rubygems