Class
abstract class Class
Defined in:
class.crprimitives.cr
Class Method Summary
- .==(other : Class)
- .===(other)
- .cast(other) : self
Casts other to this class.
- .clone
- .dup
- .hash
- .inspect(io)
- .name : String
Returns the name of this class.
- .nilable?
Returns
true
if this class isNil
- - .to_s(io)
- .|(other : U.class) forall U
Returns the union type of
self
and other.
Instance Method Summary
- #==(other : Class)
- #===(other)
- #cast(other) : self
Casts other to this class.
- #clone
- #dup
- #hash
- #inspect(io)
- #name : String
Returns the name of this class.
- #nilable?
Returns
true
if this class isNil
- - #to_s(io)
- #|(other : U.class) forall U
Returns the union type of
self
and other.
Instance methods inherited from struct Value
==(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 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
Class 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) : self from_yaml
Class Method Detail
def self.===(other)Source
def self.cast(other) : selfSource
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
def self.cloneSource
def self.dupSource
def self.hashSource
def self.inspect(io)Source
def self.nilable?Source
Returns true
if this class is Nil
-
Int32.nilable? # => false Nil.nilable? # => true
def self.to_s(io)Source
def self.|(other : U.class) forall USource
Returns the union type of self
and other.
Int32 | Char # => (Int32 | Char)
Instance Method Detail
def ===(other)Source
def cast(other) : selfSource
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
def cloneSource
def dupSource
def hashSource
def inspect(io)Source
def nilable?Source
Returns true
if this class is Nil
-
Int32.nilable? # => false Nil.nilable? # => true
def to_s(io)Source
def |(other : U.class) forall USource
Returns the union type of self
and other.
Int32 | Char # => (Int32 | Char)
© 2012–2017 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.22.0/Class.html