|
|
|
|
|
by ceeK
3799 days ago
|
|
To be honest, even as a fairly seasoned iOS developer I still prefer to have a non-optional first argument in my APIs. Whereas the post's example compares: path.addLineToPoint(CGPoint(x: 100, y: 0))
-- to --
path.addLineTo(CGPoint(x: 100, y: 0))
I've been doing it as so: path.addLine(toPoint: CGPoint(x: 100, y: 0))
...requiring the "toPoint", which can swapped out true method overloading style: path.addLine(toArc:...)
In your internal method implementation, Swift allows you to replace the external method name with an internal one, so that it's still nice to work with: func addLine(toPoint point: CGPoint) {
...
}
I personally think it's a lot more readable. Otherwise the first argument has to have a really descriptive class name (recommended for sure, but often not the case). |
|