Class

abstract class Class

Defined in:

class.cr
primitives.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.==(other : Class)Source

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.name : StringSource

Returns the name of this class.

String.name # => "String"

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 : Class)Source

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 name : StringSource

Returns the name of this class.

String.name # => "String"

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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部