Skip to content

Commit 03b596e

Browse files
authored
add syntax highlight (#1377)
1 parent d9ce7d3 commit 03b596e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

proposals/0315-placeholder-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
When Swift's type inference is unable to work out the type of a particular expression, it requires the programmer to provide the necessary type context explicitly. However, all mechanisms for doing this require the user to write out the entire type signature, even if only one portion of that type is actually needed by the compiler. E.g.,
1212

13-
```
13+
```swift
1414
let losslessStringConverter = Double.init as (String) -> Double?
1515

1616
losslessStringConverter("42") //-> 42.0
@@ -19,7 +19,7 @@ losslessStringConverter("##") //-> nil
1919

2020
In the above example, we only really need to clarify the *argument* type—there's only one `Double.init` overload that accepts a `String`. This proposal allows the user to provide type hints which use *placeholder types* in such circumstances, so that the initialization of `stringTransform` could be written as:
2121

22-
```
22+
```swift
2323
let losslessStringConverter = Double.init as (String) -> _?
2424
```
2525

0 commit comments

Comments
 (0)