Skip to content
Crystal
Type reflection
Initializing search
GitHub
Home
Specification
Guides
Tutorials
API
Compiler
Crystal
GitHub
Home
Specification
Specification
About this guide
Comments
Documenting code
Literals
Literals
Nil
Bool
Integers
Floats
Char
String
Symbol
Array
Hash
Range
Regex
Tuple
NamedTuple
Proc
Command
Assignment
Local variables
Control expressions
Control expressions
Truthy and falsey values
if
if
As a suffix
As an expression
Ternary if
if var
if var.is_a?(...)
if var.responds_to?(...)
if var.nil?
if !
unless
case
while
while
break
next
until
&&
||
Requiring files
Types and methods
Types and methods
Everything is an object
The Program
Classes and methods
Classes and methods
new, initialize and allocate
Methods and instance variables
Type inference
Union types
Overloading
Default parameter values and named arguments
Splats and tuples
Type restrictions
Return types
Method arguments
Operators
Visibility
Inheritance
Inheritance
Virtual and abstract types
Class methods
Class variables
finalize
Modules
Generics
Structs
Constants
Enums
Blocks and Procs
Blocks and Procs
Capturing blocks
Proc literal
Block forwarding
Closures
alias
Exception handling
Type grammar
Type reflection
Type reflection
is_a?
nil?
responds_to?
as
as?
typeof
Macros
Macros
Macro methods
Hooks
Fresh variables
Annotations
Annotations
Built-in annotations
Low-level primitives
Low-level primitives
pointerof
sizeof
instance_sizeof
offsetof
Uninitialized variable declaration
Compile-time flags
Compile-time flags
Cross-compilation
C bindings
C bindings
lib
fun
fun
out
to_unsafe
struct
union
enum
Variables
Constants
type
alias
Callbacks
Unsafe code
Guides
Tutorials
Tutorials
Basics
Basics
Hello World
Variables
Math
Strings
Control Flow
Methods
API
Compiler
Type reflection
¶
Crystal provides basic methods to do type reflection, casting and introspection.