3 ms·
Ever heard of `-Wunused-variable`? > rebind a variable in the same scope But only re-assigning values of the same type. Otherwise: int x = foo(); int x
by tempodox 2y ago
Ever heard of `-Wunused-variable`?
> rebind a variable in the same scope
But only re-assigning values of the same type. Otherwise:
int x = foo();
int x = bar();
error: redefinition of 'x'
and,
int x = foo();
long x = bar();
error: redefinition of 'x'
What are you talking about?
- vlovich123 2y agoIn rust it’s perfectly legal to do let x = foo() let x = bar() Regardless of the return types. That obviates a lot of the motivating problem that the c++ paper is contorting itself to fix
- tempodox 2y agoYes, borrowing some stuff from functional languages (like the ability to shadow variables) gave Rust a good boost in ergonomics.