> On Jul 26, 2015, at 16:50 , Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Jul 26, 2015, at 16:38 , Rick Mann <rm...@latencyzero.com> wrote:
>> 
>> So, is a literal 0.0 not of type Double?
> 
> No, it’s a numeric literal, so it has no numeric type. However your ‘addArc’ 
> function requires CGFloat parameters. Literal 0.0 is convertible to CGFloat, 
> but Double M_PI isn’t convertible automatically.
> 
>> And can CGFloat be made to be implicitly assignable from Double?
> 
> No. Swift doesn’t convert between numeric types automatically, so Double —> 
> CGFloat produces an error. However, many types satisfy a 
> ‘…LiteralConvertible’ protocol, which allows the compiler to treat a 
> compile-time literal such as 0 (which is ambiguous as to Swift type) to the 
> type expected in a given context.

So, why can I do this?

let n : NSNumber = M_PI




-- 
Rick Mann
rm...@latencyzero.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to