Hello!
To resolve “Scrabble score” problem, I wrote :
int score(String word) {
String s = word.toUpperCase();
int total = 0;
for (int i = 0; i < s.length; i++) {
int add = switch (s[i]) {
'A' || 'E' || 'I' || 'O' || 'U' || 'L' || 'N' || 'R' || 'S' || 'T' => 1,
'D' || 'G' => 2,
'B' || 'C' || 'M' || 'P' => 3,
'F' || 'H' || 'V' || 'W' || 'Y' => 4,
'K' => 5,
'J' || 'X' => 8,
'Q' || 'Z' => 10,
_ => 0,
};
total += add;
}
return total;
}
This code works well inDartPad but does not pass the tests here :
loading test/scrabble_score_test.dart [E] Failed to load “test/scrabble_score_test.dart”: lib/scrabble_score.dart:Expected an identifier, but got ‘switch’. Try inserting an identifier before ‘switch’.
It seems that the Dart version used in Exercism does not match the latest version of Dart. Can anyone confirm ?