3 ms·
Swift, I was once puzzled by the named function parameter, but then notice later func icon(forFile fullPath: String) -> NSImage func icon(forFiles fullPaths:
by E17D17ZUVC 4y ago
Swift, I was once puzzled by the named function parameter,
but then notice later
func icon(forFile fullPath: String) -> NSImage
func icon(forFiles fullPaths: [String]) -> NSImage?
func icon(for contentType: UTType) -> NSImage
func with same name, can have different named parameter, and return type.
func iconForFile
func iconForFiles
func iconForContentType
Will be the alternative in every other language(paramtype overload is available in c*/java/kotlin to extent, but it is less explicit), Swift sounds neat isn't it?
You can see more examples, in particularly class overloads it looks cleaner and convenient to communicate, verbosity is not an issue, code is optimised for reading.
https://developer.apple.com/documentation/appkit/nsapplication https://developer.apple.com/documentation/appkit/nsapplicati...
The actual issue with Swift, is tooling and there's SOOOOOO many hidden wanted/unwanted "feature"