dust/examples/type_inference.ds
2024-06-19 12:03:25 -04:00

21 lines
389 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")
}