fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 94: Print type of variable
Idiom # 94: Print type of variable
See
programming-idioms.org
:
Code
type_of x x.dynamic_type # For value instances `x`, this is equal to `type_of x`, but for `x` # with a `ref` type `x.dynamic_type` gives the actual runtime type, # while `type_of x` results in the static compile-time type.
What are effects?
Running Example
ex94 => x := "a string" y String := ref : String redef utf8 => x.utf8 say (type_of x) say (type_of y) # or say (x.dynamic_type) say (y.dynamic_type) # For value instances `x`, this is equal to `type_of x`, but for `x` # with a `ref` type `x.dynamic_type` gives the actual runtime type, # while `type_of x` results in the static compile-time type.
What are effects?
last changed: 2024-07-01
next: Idiom # 95: Get file size