2 ms·
I don’t know it seems fine to me tbh but maybe it’s a matter of taste. It seems pretty simple to me: everything before the colon is defining the argument name.
by skohan 6y ago
I don’t know it seems fine to me tbh but maybe it’s a matter of taste.
It seems pretty simple to me: everything before the colon is defining the argument name. If you have one label, it means the argument label is the same as the name of the parameter used inside the function. If you have two labels, then the first one is the argument label and the second one is the variable name.
You could also think of it that you’re always specifying the argument label and the variable name, and in the case where they’re identical you have a bit of shorthand to save some typing.
Maybe it seems weird to some people if it’s not familiar, but I got used to it pretty quickly after starting to use Swift, and it felt like a natural extension of the type system and optional handling in terms of the language giving me tools to cross-check things and bake sanity checks into the source code itself.
- mpweiher 6y ago> it’s a matter of taste. Probably. ¯\_(ツ)_/¯ > everything before the colon is defining the argument name. So the space binds more strongly than the colon. That seems..."unusual".