Runtime type and storage datatype
Inspect mixed values, nominal classes and explicit homogeneous arrays with type, type_of and dtype.
Download .aner source// Concrete runtime type and homogeneous storage dtype require no import.
class Sample {
let value: Any
fn kind() -> String { return type(value) }
}
let mixed = List(42, "sample", 3.5, true, null)
print(type(mixed))
print(dtype(mixed))
print(type(mixed.get(0)))
print(type_of(mixed.get(1)))
print(type(null))
let entry = Sample(value: " label ")
print(type(entry))
print(entry.kind())
print(cast<String>(mixed.get(1)).upper())
let fixed = Array<Int64>(size: 2, fill: 0)
let growing = DynamicArray<Float64>(capacity: 4)
growing.append(1.5)
let matrix = NDArray<Bool>(shape: List(2, 3), fill: false)
print(type(fixed))
print(dtype(fixed))
print(type(growing))
print(dtype(growing))
print(type(matrix))
print(dtype(matrix))
print(dtype(true))
Make it your experiment.
With Aner installed, save this program as examples/type_inspection.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/type_inspection.aner
aner run examples/type_inspection.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Use the compatible native Aner development engine with built in String methods, type and dtype, and VS Code extension 0.1.36 or newer. No import is required. Unicode indices count scalar values, not grapheme clusters or bytes; text is not normalized implicitly. dtype always reports Any for core heterogeneous containers. See String and Type inspection for checked conversions, limits and time/space complexity.
Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution