-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc cast #546
Comments
The only way to make a Tuple type without any extra unwanted temporary variable is type A = tuple[a: string, b: int]
echo A(a: "a", b: 9) # Error: object constructor needs an object type type A = tuple[a: string, b: int]
var x: A = (a: "a", b: 9) # Unwanted temporary variable.
echo x # Works type A = tuple[a: string, b: int]
echo cast[A]((a: "a", b: 9)) # Works but uses cast 🤔 |
see nim-lang/RFCs#321 which would enable |
type A = tuple[a: string, b: int]
echo A (a: "a", b: 9) |
or this works too: type A = tuple[a: string, b: int]
echo A (a: "a", b: 9)
echo A((a: "a", b: 9)) |
links
add UFCS/MCS
cast
, andaddrCast
by timotheecour · Pull Request #28 · nim-lang/fusionC++: reinterpret_cast v.s. static_cast and memory layout difference | by Xianbo QIAN | Medium
c++ - When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used? - Stack Overflow
The text was updated successfully, but these errors were encountered: