|
12 | 12 | // Intrinsic protocols shared with the compiler
|
13 | 13 | //===----------------------------------------------------------------------===//
|
14 | 14 |
|
15 |
| -/// A type that represents a Boolean value. |
16 |
| -/// |
17 |
| -/// Types that conform to the `Boolean` protocol can be used as the condition |
18 |
| -/// in control statements, such as `if` and `while`, and in other contexts |
19 |
| -/// that require a logical value, such as the `where` clause of a `case` |
20 |
| -/// statement. |
21 |
| -/// |
22 |
| -/// Swift uses only simple Boolean values in conditional contexts to help avoid |
23 |
| -/// accidental programming errors and to help maintain the clarity of each |
24 |
| -/// control statement. Unlike other programming languages, integers or strings |
25 |
| -/// cannot be used where a Boolean value is expected. |
26 |
| -/// |
27 |
| -/// For example, the following code sample will not compile, because it |
28 |
| -/// attempts to use the integer `i` in a logical context: |
29 |
| -/// |
30 |
| -/// var i = 5 |
31 |
| -/// while i { |
32 |
| -/// print(i) |
33 |
| -/// i -= 1 |
34 |
| -/// } |
35 |
| -/// |
36 |
| -/// The correct approach in Swift is to compare the `i` value with zero in the |
37 |
| -/// `while` statement. |
38 |
| -/// |
39 |
| -/// while i != 0 { |
40 |
| -/// print(i) |
41 |
| -/// i -= 1 |
42 |
| -/// } |
43 |
| -/// |
44 |
| -/// Conforming to the Boolean Protocol |
45 |
| -/// ================================== |
46 |
| -/// |
47 |
| -/// To add `Boolean` conformance to your custom type, implement a `boolValue` |
48 |
| -/// property that represents your type as an instance of `Bool`, the default |
49 |
| -/// concrete type for the `Boolean` protocol. |
50 |
| -public protocol Boolean { |
51 |
| - /// This value expressed as a `Bool` instance. |
52 |
| - var boolValue: Bool { get } |
53 |
| -} |
54 |
| - |
55 | 15 | /// A type that can be converted to and from an associated raw value.
|
56 | 16 | ///
|
57 | 17 | /// With a `RawRepresentable` type, you can switch back and forth between a
|
@@ -701,8 +661,8 @@ public protocol _ExpressibleByFileReferenceLiteral {
|
701 | 661 | public protocol _DestructorSafeContainer {
|
702 | 662 | }
|
703 | 663 |
|
704 |
| -@available(*, unavailable, renamed: "Boolean") |
705 |
| -public typealias BooleanType = Boolean |
| 664 | +@available(*, unavailable, renamed: "Bool") |
| 665 | +public typealias BooleanType = Bool |
706 | 666 |
|
707 | 667 | // Deprecated by SE-0115.
|
708 | 668 |
|
|
0 commit comments