dust/examples/type_inference.ds
2024-08-13 22:25:33 -04:00

21 lines
384 B
Plaintext

// This function returns its argument.
foo = fn <T>(x: T) -> T { x }
// Use turbofish to supply type information.
bar = foo::<str>("hi")
// Use type annotation
baz: str = foo("hi")
// The `json.parse` function takes a string and returns the specified type
// Use turbofish
x = json.parse::<int>("1")
// Use type annotation
x: int = json.parse("1")
x: int = {
json.parse("1")
}