Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9915] Documentation: type(of:) documentation snippet does not compile #52321

Closed
ktoso opened this issue Feb 13, 2019 · 3 comments
Closed
Assignees
Labels

Comments

@ktoso
Copy link
Member

ktoso commented Feb 13, 2019

Previous ID SR-9915
Radar None
Original Reporter @ktoso
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement, Documentation
Assignee @ktoso
Priority Medium

md5: 4034e73111f733319a978b85785e968b

Issue Description:

Just a small typo / mistake in documentation snippet. Explained below, I'll provide a PR fixing this shortly.

Where:

Documentation of`type(of)`: https://developer.apple.com/documentation/swift/2885064-type

Which snippet:

func printGenericInfo<T>(_ value: T) {
    let type = type(of: value)
    print("'\(value)' of type '\(type)'")
}

protocol P {}
extension String: P {}

let stringAsP: P = "Hello!"
printGenericInfo(stringAsP)
// 'Hello!' of type 'P'

Fails in this way when attempted to copy verbatim to try out:

error: repl.swift:2:16: error: variable used within its own initial value
    let type = type(of: value)
               ^

Will provide a small PR fixing this shortly.

@ktoso
Copy link
Member Author

ktoso commented Feb 13, 2019

Pull request: #22575

@ktoso
Copy link
Member Author

ktoso commented Feb 15, 2019

PR was merged.

@ktoso
Copy link
Member Author

ktoso commented Jun 24, 2021

was fixed

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant