File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ divide(10, by: 0) // returns 0
132132fun processAge(_ age: Int): String {
133133 if age >= 0 {
134134 if age <= 150 {
135- return "Valid age: ".concat (age.toString())
135+ return "Valid age: \ (age)"
136136 } else {
137137 return "Too old"
138138 }
@@ -149,7 +149,7 @@ fun processAge(_ age: Int): String {
149149 guard age <= 150 else {
150150 return "Too old"
151151 }
152- return "Valid age: ".concat (age.toString())
152+ return "Valid age: \ (age)"
153153}
154154```
155155
@@ -163,7 +163,7 @@ fun greet(_ name: String?): String {
163163 return "Hello, stranger"
164164 }
165165 // `unwrappedName` is available here, already unwrapped to `String`
166- return "Hello, ".concat (unwrappedName)
166+ return "Hello, \ (unwrappedName)"
167167}
168168
169169greet("Alice") // returns "Hello, Alice"
@@ -176,7 +176,7 @@ Contrast with `if let`:
176176fun greet(_ name: String?): String {
177177 if let unwrappedName = name {
178178 // `unwrappedName` only exists inside this block
179- return "Hello, ".concat (unwrappedName)
179+ return "Hello, \ (unwrappedName)"
180180 }
181181 return "Hello, stranger"
182182 // `unwrappedName` is NOT available here
You can’t perform that action at this time.
0 commit comments