1
0
dust/examples/type_inference.ds

21 lines
384 B
Plaintext
Raw Permalink Normal View History

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