Skip to content

Commit 837ead3

Browse files
committed
Track 'main'.
2 parents acc3cfc + f055a20 commit 837ead3

File tree

5 files changed

+98
-209
lines changed

5 files changed

+98
-209
lines changed

Sources/TSPL/TSPL.docc/GuidedTour/GuidedTour.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ occupations["Jayne"] = "Public Relations"
263263
```
264264
-->
265265

266+
<!--
267+
iBooks Store screenshot begins here.
268+
-->
269+
266270
Arrays automatically grow as you add elements.
267271

268272
```swift
@@ -280,44 +284,43 @@ print(fruits)
280284
```
281285
-->
282286

283-
To create an empty array or dictionary,
284-
use the initializer syntax.
287+
You also use brackets to write an empty array or dictionary.
288+
For an array, write `[]`,
289+
and for a dictionary, write `[:]`.
285290

286291
```swift
287-
let emptyArray: [String] = []
288-
let emptyDictionary: [String: Float] = [:]
292+
fruits = []
293+
occupations = [:]
289294
```
290295

291296
<!--
292297
- test: `guided-tour`
293298
294299
```swifttest
295-
-> let emptyArray: [String] = []
296-
-> let emptyDictionary: [String: Float] = [:]
300+
-> fruits = []
301+
-> occupations = [:]
297302
```
298303
-->
299304

300-
If type information can be inferred,
301-
you can write an empty array as `[]`
302-
and an empty dictionary as `[:]` ---
303-
for example, when you set a new value for a variable
304-
or pass an argument to a function.
305-
306-
<!--
307-
iBooks Store screenshot begins here.
308-
-->
305+
If you're assigning an empty array or dictionary to a new variable,
306+
or another place where there isn't any type information,
307+
you need to specify the type.
309308

310309
```swift
311-
fruits = []
312-
occupations = [:]
310+
let emptyArray: [String] = []
311+
let emptyDictionary: [String: Float] = [:]
313312
```
314313

314+
315315
<!--
316316
- test: `guided-tour`
317317
318318
```swifttest
319-
-> fruits = []
320-
-> occupations = [:]
319+
-> let emptyArray: [String] = []
320+
-> let emptyDictionary: [String: Float] = [:]
321+
---
322+
-> let anotherEmptyArray = [String]()
323+
-> let emptyDictionary = [String: Float]()
321324
```
322325
-->
323326

0 commit comments

Comments
 (0)