Skip to content

Commit ee49b93

Browse files
committed
Fix the empty array/dict example.
These two examples used to contrast the initializer and literal syntax. When we moved all of TSPL away from initializer syntax [1], that contrast was lost, resulting in a confusing example. 1: 639bcc6
1 parent fd82527 commit ee49b93

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ occupations["Jayne"] = "Public Relations"
274274
```
275275
-->
276276

277+
@Comment {
278+
iBooks Store screenshot begins here.
279+
}
280+
277281
Arrays automatically grow as you add elements.
278282

279283
```swift
@@ -292,21 +296,23 @@ print(fruits)
292296
```
293297
-->
294298

295-
To create an empty array or dictionary,
296-
use the initializer syntax.
299+
To create an empty array, write `[]`
300+
and to create empty dictionary write `[:]` ---
301+
for example, when you set a new value for a variable
302+
or pass an argument to a function.
297303

298304
```swift
299-
let emptyArray: [String] = []
300-
let emptyDictionary: [String: Float] = [:]
305+
fruits = []
306+
occupations = [:]
301307
```
302308

303309

304310
<!--
305311
- test: `guided-tour`
306312
307313
```swifttest
308-
-> let emptyArray: [String] = []
309-
-> let emptyDictionary: [String: Float] = [:]
314+
-> fruits = []
315+
-> occupations = [:]
310316
```
311317
-->
312318

@@ -321,17 +327,20 @@ or pass an argument to a function.
321327
-->
322328

323329
```swift
324-
fruits = []
325-
occupations = [:]
330+
let emptyArray: [String] = []
331+
let emptyDictionary: [String: Float] = [:]
326332
```
327333

328334

329335
<!--
330336
- test: `guided-tour`
331337
332338
```swifttest
333-
-> fruits = []
334-
-> occupations = [:]
339+
-> let emptyArray: [String] = []
340+
-> let emptyDictionary: [String: Float] = [:]
341+
---
342+
-> let anotherEmptyArray = [String]()
343+
-> let emptyDictionary = [String: Float]()
335344
```
336345
-->
337346

0 commit comments

Comments
 (0)