class Crystal::Const
inherits Crystal::NamedType
¶
A constant inside a type. For example, given:
class Foo
A = 1
end
A
will be a Const type with a value of 1.
A constant is a type because when we do Foo::A
we do a regular
type lookup, which might result in a constant, so constants are
saved under a type types like any other type.
Class methods¶
Methods¶
#compile_time_value
¶
Returns a value if this constant's value can be evaluated at
compile time (things like 1 + 2
and such). Returns nil otherwise.
#no_init_flag=(no_init_flag)
¶
(no_init_flag)
If true, there's no need to check whether the constant was initialized or not when reading it.
#no_init_flag? : Bool
¶
: Bool
If true, there's no need to check whether the constant was initialized or not when reading it.
#read=(read)
¶
(read)
Was this constant already read during the codegen phase?
If not, and we are at the place that declares the constant, we can
directly initialize the constant now, without checking for an init
flag.
#read? : Bool
¶
: Bool
Was this constant already read during the codegen phase?
If not, and we are at the place that declares the constant, we can
directly initialize the constant now, without checking for an init
flag.
#simple?
¶
Returns true
if this constant's value is a simple literal, like
nil
, a number, char, string or symbol literal.