2024-06-19 03:32:51 -04:00
|
|
|
// This function returns its argument.
|
2024-06-26 11:35:39 -04:00
|
|
|
foo = fn <T>(x: T) -> T { x }
|
2024-06-19 03:32:51 -04:00
|
|
|
|
|
|
|
// Use turbofish to supply type information.
|
2024-06-26 11:35:39 -04:00
|
|
|
bar = foo::<str>("hi")
|
2024-06-19 03:32:51 -04:00
|
|
|
|
|
|
|
// Use type annotation
|
2024-06-19 00:22:37 -04:00
|
|
|
baz: str = foo("hi")
|
2024-06-19 03:32:51 -04:00
|
|
|
|
|
|
|
// 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")
|
2024-06-19 03:32:51 -04:00
|
|
|
|
|
|
|
// 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")
|
|
|
|
}
|