
上QQ阅读APP看书,第一时间看更新
String interpolation
Dart has a useful syntax to interpolate the value of Dart expressions within strings: ${}, which works as follows:
main() {
String someString = "This is a String";
print("The string value is: $someString ");
// prints The string value is: This is a String
print("The length of the string is: ${someString.length} ");
// prints The length of the string is: 16
}
As you may have noticed, when we are inserting just a variable and not an expression value into the string, we can omit the braces and just add $identifier directly.
Dart also has the runes concept to represent UTF-32 bits. For more details, check out the Dart language tour: https://dart.dev/guides/language/language-tour.