• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGFloat and literal floats in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGFloat and literal floats in Swift


  • Subject: Re: CGFloat and literal floats in Swift
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 26 Jul 2015 23:50:36 +0000

On Jul 26, 2015, at 16:38 , Rick Mann <email@hidden> 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.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: CGFloat and literal floats in Swift
      • From: Jens Alfke <email@hidden>
    • Re: CGFloat and literal floats in Swift
      • From: Rick Mann <email@hidden>
References: 
 >CGFloat and literal floats in Swift (From: Rick Mann <email@hidden>)
 >Re: CGFloat and literal floats in Swift (From: Quincey Morris <email@hidden>)
 >Re: CGFloat and literal floats in Swift (From: Rick Mann <email@hidden>)
 >Re: CGFloat and literal floats in Swift (From: Quincey Morris <email@hidden>)
 >Re: CGFloat and literal floats in Swift (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Generics Question
  • Next by Date: Re: CGFloat and literal floats in Swift
  • Previous by thread: Re: CGFloat and literal floats in Swift
  • Next by thread: Re: CGFloat and literal floats in Swift
  • Index(es):
    • Date
    • Thread