Browse Source

Merge pull request #306 from foobit/string.docs

added example on inline string formatting
Marco Bambini 5 years ago
parent
commit
eebf357e14
1 changed files with 7 additions and 0 deletions
  1. 7 0
      docs/string.md

+ 7 - 0
docs/string.md

@@ -52,3 +52,10 @@ Strings are an immutable sequence of characters. String literals can be surround
 	var str = "momo"
 	var str = "momo"
 	str.replace("o", "i") // returns mimi
 	str.replace("o", "i") // returns mimi
 ```
 ```
+
+Strings can contain inline expressions with backslash and parentheses.
+```swift
+	var amount = 7
+	var fruit = "apples"
+	var n = "You have \(amount) \(fruit)!"  // n is now "You have 7 apples!"
+```