jlandon / Alexandria

A library of Swift extensions to turbocharge your iOS development.
https://jlandon.github.io/Alexandria
MIT License
65 stars 8 forks source link

Removing the alpha argument to make the UIColor convenience initializer unique #9

Closed hsoi closed 8 years ago

hsoi commented 8 years ago

Originally I had code like this:

UIColor(red: 78/255, green: 43/255, blue: 96/255, alpha: 1)

Which was fine until I added Alexandria. But now I get an error:

Ambiguous use of operator /

So ok... I change it: UIColor(red: 81, green: 45, blue: 109, alpha: 1) and now:

ambiguous use of init(red:green:blue:alpha:)

I guess this is an interesting case... we're overloading the function -- the NAME of the function is the same, but the argument types are not.

if I remove the explicit alpha argument, no problems....

And so, after some discussion, we agreed to just remove the alpha argument because it's a convenience initializer and we're using it for shortcuts/convenience. Most of the time you'll want a 1.0 alpha anyways so... this just makes it a little more convenient.

jlandon commented 8 years ago

:+1: