1
0
dust/examples/type_inference.ds

21 lines
384 B
Plaintext
Raw Normal View History

// This function returns its argument.
2024-06-26 11:35:39 -04:00
foo = fn <T>(x: T) -> T { x }
// Use turbofish to supply type information.
2024-06-26 11:35:39 -04:00
bar = foo::<str>("hi")
// Use type annotation
2024-06-19 00:22:37 -04:00
baz: str = foo("hi")
// The `json.parse` function takes a string and returns the specified type
// Use turbofish
2024-06-26 11:35:39 -04:00
x = json.parse::<int>("1")
// Use type annotation
2024-06-19 02:32:17 -04:00
x: int = json.parse("1")
2024-06-19 12:03:25 -04:00
x: int = {
json.parse("1")
}