• 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
Swift Generics Error When Enforcing Protocol Conformance...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Swift Generics Error When Enforcing Protocol Conformance...


  • Subject: Swift Generics Error When Enforcing Protocol Conformance...
  • From: "Peters, Brandon" <email@hidden>
  • Date: Thu, 24 Dec 2015 06:08:05 +0000
  • Thread-topic: Swift Generics Error When Enforcing Protocol Conformance...

All,

I have two function signatures for the following:

func linconv<T: FloatingPointType>(signal_A signal_A: [T], signal_B: [T]) -> [T]? {

    var arr = [T](count: 4, repeatedValue: 0.0)

    return nil
}

func linconv<T: IntegerType>(signal_A signal_A: [T], signal_B: [T]) -> [T]? {

    var arr = [T](count: 4, repeatedValue: 0)

    return nil
}

An error is called on the array initialization in the first case but not the second. The error message reads "Cannot invoke initializer for type '[T]' with an argument list of type '(count: Int, repeatedValue: Double)’”. Has anyone seen this? Is it a bug? It makes sense to me (so far anyway) that both should compile.

_______________________________________________

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: Swift Generics Error When Enforcing Protocol Conformance...
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Hurdles in converting to Swift
  • Next by Date: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • Previous by thread: Re: Hurdles in converting to Swift
  • Next by thread: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • Index(es):
    • Date
    • Thread