I am going through the language tour and, coming from a mostly Javascript background, I’m having trouble understanding how to destructure this record.
(int, String, {String b, String c}) rec = (7, c:"testc", "positionaltest", b:"testb");
String (:b) = rec;
print(b); // Expecting "testb"
Apparently dart is trying to assign the entire record rather than destructuring, because if I try to grab a positional value instead, it doesn’t throw an error, but it instead assigns the entire record to the variable.
(int, String, {String b, String c}) rec = (7, c:"testc", "positionaltest", b:"testb");
String (a) = rec;
print(a); // Expecting 7
So far I’ve only gotten to the Records page, and this is my first encounter with destructuring in Dart.
Why are my examples not working as I expect, and what is the correct way to do them?
Using Dart 3.4.4