You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Language Guide Checking API Availability subsection, at the beginning of the third paragraph the text states:
You can use an availability condition in an if or guard statement to conditionally execute a block of code, depending on whether the APIs you want to use are available at runtime.
All subsequent text and examples in the subsection support this.
In the Language Reference Availability Condition subsection, the first paragraph reads:
An availability condition is used as a condition of an if, while, and guard statement to query the availability of APIs at runtime, based on specified platforms arguments.
The grammar is sufficiently vague as to permit an API availability check in these and many other locations, where it doesn't appear to be semantically allowed.
Xcode doesn't yield diagnostics when an API availability is given in a while statement, but does for a repeat-while statement.
Correction
Reword the first sentence in the Language Guide Checking API Availability subsection to read:
You can use an availability condition in an if, guard, or while statement to conditionally execute a block of code, depending on whether the APIs you want to use are available at runtime.
An example shouldn't be necessary as using an API availability check is an unlikely occurance.
The text was updated successfully, but these errors were encountered:
Location
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/controlflow#Checking-API-Availability
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/statements#Availability-Condition
Description
In the Language Guide Checking API Availability subsection, at the beginning of the third paragraph the text states:
You can use an availability condition in an if or guard statement to conditionally execute a block of code, depending on whether the APIs you want to use are available at runtime.
All subsequent text and examples in the subsection support this.
In the Language Reference Availability Condition subsection, the first paragraph reads:
An availability condition is used as a condition of an if, while, and guard statement to query the availability of APIs at runtime, based on specified platforms arguments.
The grammar is sufficiently vague as to permit an API availability check in these and many other locations, where it doesn't appear to be semantically allowed.
Xcode doesn't yield diagnostics when an API availability is given in a while statement, but does for a repeat-while statement.
Correction
Reword the first sentence in the Language Guide Checking API Availability subsection to read:
You can use an availability condition in an if, guard, or while statement to conditionally execute a block of code, depending on whether the APIs you want to use are available at runtime.
An example shouldn't be necessary as using an API availability check is an unlikely occurance.
The text was updated successfully, but these errors were encountered: