abstract class Class
Defined in:
class.crprimitives.cr
Constructors
-
.cast(other) : self
Casts other to this class.
Class Method Summary
-
.<(other : T.class) : Bool forall T
Returns whether this class inherits or includes other.
-
.<=(other : T.class) : Bool forall T
Returns whether this class inherits or includes other, or is equal to other.
-
.==(other : Class) : Bool
Returns whether this class is the same as other.
- .===(other)
-
.>(other : T.class) forall T
Returns whether other inherits or includes
self. -
.>=(other : T.class) forall T
Returns whether other inherits or includes
self, or is equal toself. - .clone
- .dup
- .hash(hasher)
- .inspect(io)
-
.name : String
Returns the name of this class.
-
.nilable?
Returns
trueif this class isNil. - .to_s(io)
-
.|(other : U.class) forall U
Returns the union type of
selfand other.
Instance Method Summary
-
#<(other : T.class) : Bool forall T
Returns whether this class inherits or includes other.
-
#<=(other : T.class) : Bool forall T
Returns whether this class inherits or includes other, or is equal to other.
-
#==(other : Class) : Bool
Returns whether this class is the same as other.
- #===(other)
-
#>(other : T.class) forall T
Returns whether other inherits or includes
self. -
#>=(other : T.class) forall T
Returns whether other inherits or includes
self, or is equal toself. -
#cast(other) : self
Casts other to this class.
- #clone
- #dup
- #hash(hasher)
- #inspect(io)
-
#name : String
Returns the name of this class.
-
#nilable?
Returns
trueif this class isNil. - #to_s(io)
-
#|(other : U.class) forall U
Returns the union type of
selfand other.
Instance methods inherited from struct Value
==(other : JSON::Any)==(other : YAML::Any)
==(other) ==, dup dup
Instance methods inherited from class Object
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other : JSON::Any)===(other : YAML::Any)
===(other) ===, =~(other) =~, class class, dup dup, hash(hasher)
hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, tap(&block) tap, to_json(io : IO)
to_json to_json, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ") to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml(io : IO)
to_yaml to_yaml, try(&block) try, unsafe_as(type : T.class) forall T unsafe_as
Constructor methods inherited from class Object
from_json(string_or_io, root : String) : selffrom_json(string_or_io) : self from_json, from_yaml(string_or_io : String | IO) : self from_yaml
Constructor Detail
Casts other to this class.
This is the same as using as, but allows the class to be passed around as
an argument. See the
documentation on as
for more information.
klass = Int32
number = [99, "str"][0]
typeof(number) # => (String | Int32)
typeof(klass.cast(number)) # => Int32Class Method Detail
Returns whether this class inherits or includes other.
Int32 < Number # => true
Int32 < Value # => true
Int32 < Int32 # => false
Int32 <= String # => falseReturns whether this class inherits or includes other, or is equal to other.
Int32 < Number # => true
Int32 < Value # => true
Int32 <= Int32 # => true
Int32 <= String # => falseReturns whether this class is the same as other.
Int32 == Int32 # => true
Int32 == String # => falseReturns whether other inherits or includes self.
Number > Int32 # => true
Number > Number # => false
Number > Object # => falseReturns whether other inherits or includes self, or is equal
to self.
Number >= Int32 # => true
Number >= Number # => true
Number >= Object # => falseReturns true if this class is Nil.
Int32.nilable? # => false
Nil.nilable? # => trueReturns the union type of self and other.
Int32 | Char # => (Int32 | Char)Instance Method Detail
Returns whether this class inherits or includes other.
Int32 < Number # => true
Int32 < Value # => true
Int32 < Int32 # => false
Int32 <= String # => falseReturns whether this class inherits or includes other, or is equal to other.
Int32 < Number # => true
Int32 < Value # => true
Int32 <= Int32 # => true
Int32 <= String # => falseReturns whether this class is the same as other.
Int32 == Int32 # => true
Int32 == String # => falseReturns whether other inherits or includes self.
Number > Int32 # => true
Number > Number # => false
Number > Object # => falseReturns whether other inherits or includes self, or is equal
to self.
Number >= Int32 # => true
Number >= Number # => true
Number >= Object # => falseCasts other to this class.
This is the same as using as, but allows the class to be passed around as
an argument. See the
documentation on as
for more information.
klass = Int32
number = [99, "str"][0]
typeof(number) # => (String | Int32)
typeof(klass.cast(number)) # => Int32Returns the union type of self and other.
Int32 | Char # => (Int32 | Char)