For example, sqrt(x)
. Based on my searches (perhaps most helpfully here), I know that I can import Darwin or UIKit, etc, and get sqrt to work. (Or as per here, .squareRoot()
) But for the future, with who knows what function I want to use, how do I find that out on my own without somebody having already asked that here?
In C++ (what I'm more used to), all I have to do is go to any sort of C++ documentation site, search sqrt or square root, and I find out I should include cmath or math.h, and if I want to see what else is in cmath, that's super easy, I just click on it.
But I am having an absolutely terrible time trying to do similar with Swift. If I search either built-in or online documentation, the best searching for sqrt gets me is this, but this has absolutely no indication that I could use this by importing Darwin, not to mention a total lack of description. (Searching square root does find the .squareRoot()
luckily, but that's not needing import, so isn't really the question)
Even if I already know (or guess) and import it, then option-click sqrt after I type it, it lets me know it exists and is part of Darwin.C.math, but I can't even click on that to see what else there is in that.
How do you learn this stuff?