You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the existence of the any type, type inference is necessary. However, the method similar to golang any.(Type) requires one small symbol, one large symbol, and two parentheses, which can be cumbersome. Therefore, I would like to refer to the as method in Rust and TypeScript.
Type casting
var foo = 1
var bar = foo as bool // bar type is bool
Type assertion
any foo = 1
var bar = any is int // bar type is int
One point that is quite tangled is whether the "is" syntax is necessary, or whether to use the "as" syntax uniformly, both for type assertions and type conversions. 🤔
The text was updated successfully, but these errors were encountered:
weiwenhao
changed the title
About casts and type inference syntax
proposal: type casts and type inference syntax
May 16, 2023
Due to the existence of the
any
type, type inference is necessary. However, the method similar to golangany.(Type)
requires one small symbol, one large symbol, and two parentheses, which can be cumbersome. Therefore, I would like to refer to theas
method in Rust and TypeScript.Type casting
Type assertion
One point that is quite tangled is whether the "is" syntax is necessary, or whether to use the "as" syntax uniformly, both for type assertions and type conversions. 🤔
The text was updated successfully, but these errors were encountered: