Dart字符串前面的@是什么意思
What does @ in front of a Dart string mean
我发现一些 Dart 代码在字符串前面带有 @:
_specialCharactersInsideCharacterClass = new HashSet.from([@"^", @"-", @"]"]);
在这种情况下符号@是什么意思?
现在,字符串前面的前缀 @
字符不是有效的 Dart 代码。但我可以想象它被用来禁用转义和字符串插值 in the past. The linked Dart file is from 2013, so maybe it was created before the prefix r
was introduced to mark raw strings:
_specialCharactersInsideCharacterClass = new HashSet.from([r"^", r"-", r"]"]);
在原始字符串中,字符串插值(使用 $
字符)和转义(例如 \r
)被禁用。
我发现一些 Dart 代码在字符串前面带有 @:
_specialCharactersInsideCharacterClass = new HashSet.from([@"^", @"-", @"]"]);
在这种情况下符号@是什么意思?
现在,字符串前面的前缀 @
字符不是有效的 Dart 代码。但我可以想象它被用来禁用转义和字符串插值 in the past. The linked Dart file is from 2013, so maybe it was created before the prefix r
was introduced to mark raw strings:
_specialCharactersInsideCharacterClass = new HashSet.from([r"^", r"-", r"]"]);
在原始字符串中,字符串插值(使用 $
字符)和转义(例如 \r
)被禁用。