Casts other to this class.
Returns whether this class inherits or includes other.
Returns whether this class inherits or includes other, or is equal to other.
Returns whether this class is the same as other.
Case equality.
Returns whether other inherits or includes self
.
Returns whether other inherits or includes self
, or is equal to self
.
Returns a shallow copy of this object.
Appends a string representation of this object to the given IO
object.
Returns the name of this class.
Returns true
if this class is Nil
.
Returns the union type of self
and other.
Returns whether this class inherits or includes other.
Returns whether this class inherits or includes other, or is equal to other.
Returns whether this class is the same as other.
Case equality.
Returns whether other inherits or includes self
.
Returns whether other inherits or includes self
, or is equal to self
.
Casts other to this class.
Returns a shallow copy of this object.
Appends a string representation of this object to the given IO
object.
Returns the name of this class.
Returns true
if this class is Nil
.
Returns the union type of self
and other.
Value
Object
Object
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)) # => Int32
Returns whether this class inherits or includes other.
Int32 < Number # => true Int32 < Value # => true Int32 < Int32 # => false Int32 <= String # => false
Returns whether this class inherits or includes other, or is equal to other.
Int32 < Number # => true Int32 < Value # => true Int32 <= Int32 # => true Int32 <= String # => false
Returns whether this class is the same as other.
Int32 == Int32 # => true Int32 == String # => false
Case equality.
The #===
method is used in a case ... when ... end
expression.
For example, this code:
case value when x # something when x when y # something when y end
Is equivalent to this code:
if x === value # something when x elsif y === value # something when y end
Object simply implements #===
by invoking #==
, but subclasses (notably Regex
) can override it to provide meaningful case-equality semantics.
Returns whether other inherits or includes self
.
Number > Int32 # => true Number > Number # => false Number > Object # => false
Returns whether other inherits or includes self
, or is equal to self
.
Number >= Int32 # => true Number >= Number # => true Number >= Object # => false
Returns true
if this class is Nil
.
Int32.nilable? # => false Nil.nilable? # => true
Returns the union type of self
and other.
Int32 | Char # => (Int32 | Char)
Returns whether this class inherits or includes other.
Int32 < Number # => true Int32 < Value # => true Int32 < Int32 # => false Int32 <= String # => false
Returns whether this class inherits or includes other, or is equal to other.
Int32 < Number # => true Int32 < Value # => true Int32 <= Int32 # => true Int32 <= String # => false
Returns whether this class is the same as other.
Int32 == Int32 # => true Int32 == String # => false
Case equality.
The #===
method is used in a case ... when ... end
expression.
For example, this code:
case value when x # something when x when y # something when y end
Is equivalent to this code:
if x === value # something when x elsif y === value # something when y end
Object simply implements #===
by invoking #==
, but subclasses (notably Regex
) can override it to provide meaningful case-equality semantics.
Returns whether other inherits or includes self
.
Number > Int32 # => true Number > Number # => false Number > Object # => false
Returns whether other inherits or includes self
, or is equal to self
.
Number >= Int32 # => true Number >= Number # => true Number >= Object # => false
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)) # => Int32
Returns true
if this class is Nil
.
Int32.nilable? # => false Nil.nilable? # => true
Returns the union type of self
and other.
Int32 | Char # => (Int32 | Char)
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Class.html