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