1
0
dust/examples/type_inference.ds

21 lines
389 B
Plaintext
Raw Normal View History

// This function returns its argument.
2024-06-19 04:05:58 +00:00
foo = fn |T| (x: T) -> T { x }
// Use turbofish to supply type information.
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-19 06:32:17 +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")
}