3 ms·
Well, lucky for you "var x, y, z" is never going to happen in a statically typed language. dynamic, on the other hand....<looks shiftily into C#'s direction>
by deanCommie 11y ago
Well, lucky for you "var x, y, z" is never going to happen in a statically typed language.
dynamic, on the other hand....<looks shiftily into C#'s direction>
J/K. I Love dynamics.
- masklinn 11y ago> Well, lucky for you "var x, y, z" is never going to happen in a statically typed language. Why not? let (a, b, c); is perfectly valid Rust, it just declares 3 locals a, b and c.
- gravypod 11y agoWhat type are they?
- heinrich5991 11y agoDepends on what you assign to these variables. fn main() { let (a, b, c); a = true; b = [1]; c = "foobar"; } https://play.rust-lang.org/?gist=ebedd0cd5b6707410aff&version=stable https://play.rust-lang.org/?gist=ebedd0cd5b6707410aff&versio...
- gravypod 11y agoThat's my problem. YOU can't tell. You cannot just look and see what is going on.
- masklinn 11y agoSure you can, it's pretty clear that a is a boolean, b is an array on the stack and c is a string. If the code is so complex you can't eyeball a local scope you probably have bigger problems than whatever the type of the variables are, and if you get one wrong the compiler will yell at you.
- masklinn 11y agoWhatever type the compiler infers based on the assignments you make afterwards (and a compilation error if there isn't any/enough information to infer the type).