title: Can I use Swift's map() on Protocols?
body: <p>I have some model code where I have some <code>Thought</code>s that i want to read and write to plists. I have the following code:</p>
  
  <pre><code>protocol Note {
      var body: String { get }
      var author: String { get }
      var favorite: Bool { get set }
      var creationDate: Date { get }
      var id: UUID { get }
      var plistRepresentation: [String: Any] { get }
      init(plist: [String: Any])
  }
  
  struct Thought: Note {
      let body: String
      let author: String
      var favorite: Bool
      let creationDate: Date
      let id: UUID
  }
  
  extension Thought {
      var plistRepresentation: [String: Any] {
          return [
              "body": body as Any,
              "author": author as Any,
              "favorite": favorite as Any,
              "creationDate": creationDate as Any,
              "id": id.uuidString as Any
          ]
      }
  
      init(plist: [String: Any]) {
          body = plist["body"] as! String
          author = plist["author"] as! String
          favorite = plist["favorite"] as! Bool
          creationDate = plist["creationDate"] as! Date
          id = UUID(uuidString: plist["id"] as! String)!
      }
  }
  </code></pre>
  
  <p>for my data model, then down in my data write controller I have this method:</p>
  
  <pre><code>func fetchNotes() -&gt; [Note] {
      guard let notePlists = NSArray(contentsOf: notesFileURL) as? [[String: Any]] else {
          return []
      }
      return notePlists.map(Note.init(plist:))
  }
  </code></pre>
  
  <p>For some reason the line <code>return notePlists.map(Note.init(plist:))</code> gives the error <code>'map' produces '[T]', not the expected contextual result type '[Note]'</code>
  However, If I replace the line with <code>return notePlists.map(Thought.init(plist:))</code> I have no issues. Clearly I can't map the initializer of a protocol? Why not and what's an alternate solution?</p>