@@ -1889,7 +1889,7 @@ even though the doubling operation could really apply
18891889to any number of arguments.
18901890
18911891Other approaches that also have drawbacks
1892- include taking the arguments an array or a variadic parameter,
1892+ include taking the arguments as an array or a variadic parameter,
18931893which requires all arguments to be the same type,
18941894or using ` Any ` which erases type information.
18951895
@@ -1905,12 +1905,11 @@ func double<each T: Numeric>(_ value: repeat each T) -> (repeat each T) {
19051905}
19061906```
19071907
1908- In the code above, ` Element ` is a generic type parameter.
1909- It's marked ` each Element ` ,
1910- indicating that it's a type-parameter pack.
1908+ In the code above, ` each T ` is declared in a generic parameter list.
1909+ It's marked with ` each ` , indicating that it's a type parameter pack.
19111910In contrast to a generic type parameter,
19121911which serves as a placeholder for a single type,
1913- a type- parameter pack is a placeholder for multiple types.
1912+ a type parameter pack is a placeholder for multiple types.
19141913The ability to have ` T ` contain a varying number of types
19151914is what allows this version of ` double(_:) `
19161915to take any number of parameters
@@ -1933,7 +1932,7 @@ extension Numeric {
19331932}
19341933
19351934let numbers = [12 , 0.5 , 8 as Int8 ]
1936- let doubledNumbers = double (numbers)
1935+ let doubledNumbers = doubled (numbers)
19371936```
19381937
19391938The value of ` doubledNumbers ` is ` (24, 1.0, 16) ` ,
@@ -1980,7 +1979,7 @@ How do you create a parameter pack?
19801979 and in function argument lists.
19811980
19821981 ``` swift
1983- func f <each T >(_ t : repeat each T) -> repeat each T
1982+ func f <each T >(_ t : repeat each T) -> ( repeat each T)
19841983 ```
19851984
19861985- The expansion pattern is repeated for every element in the given type pack
@@ -2035,8 +2034,8 @@ How do you constrain the types in a parameter pack?
20352034- In the more complex case,
20362035 use ` repeat each T ` in a trailing ` where ` clause.
20372036
2038- - You must restrict the types that appear in a type- parameter pack;
2039- conformance requirements don't implicitly propagate .
2037+ - You must restrict the types that appear in a type parameter pack
2038+ if its expansion will be used as a restricted generic type parameter .
20402039 For example, given ` each T: Hashable ` writing ` repeat Set<each T> ` works,
20412040 but it doesn't work with just ` each T `
20422041 because ` Set ` requires ` T ` to be hashable but the pack doesn't.
@@ -2062,7 +2061,7 @@ How do you access the values of a parameter pack?
20622061 ```
20632062
20642063- The result (and its type) of expanding a parameter pack
2065- vary depending on the number of elements in the pack.
2064+ within a tuple vary depending on the number of elements in the pack.
20662065 Zero-element packs produce ` () ` ,
20672066 single-element packs produce a simple type,
20682067 and multi-element packs produce a tuple type.
@@ -2073,7 +2072,7 @@ How do you access the values of a parameter pack?
20732072
20742073 For example,
20752074 ` repeat (each T, Int) ` is different from ` (repeat each T, Int) ` .
2076- The former makes multiple tuple ` (T1, Int) ... (Tn, Int) ` ,
2075+ The former makes multiple tuples ` (T1, Int) ... (Tn, Int) ` ,
20772076 expanding ` T ` and adding ` Int ` to each tuple.
20782077 The latter makes one tuple, ` (T1, ..., Tn, Int) ` .
20792078 Other code can come between ` repeat ` and ` each ` ---
0 commit comments