title: How to extend a function of a protocol in swift 3?
body: <p>I have following code:</p>
  
  <pre><code>protocol Protocol_1 {
      var prop_1: String { get set }
      var prop_2: Int { get set }
  }
  
  protocol Protocol_2 {
      var prop_3: Double { get set }
      var prop_4: Bool { get set }
  }
  
  extension Protocol_1 {
      mutating func set&lt;T&gt;(value: T, forKey key: String)
      {
          switch key {
          case "prop_1":
              if value is String {
                  prop_1 = value as! String
              }
  
          case "prop_2":
              if value is Int {
                  prop_2 = value as! Int
              }
  
          default:
              break
          }
      }
  }
  
  extension Protocol_2 {
      mutating func set&lt;T&gt;(value: T, forKey key: String)
      {
          switch key {
          case "prop_3":
              if value is Double {
                  prop_3 = value as! Double
              }
  
          case "prop_4":
              if value is Bool {
                  prop_4 = value as! Bool
              }
  
          default:
              break
          }
      }
  }
  
  struct MyStruct : Protocol_1, Protocol_2 {
      var prop_1: String
      var prop_2: Int
      var prop_3: Double
      var prop_4: Bool
  }
  
  var myStruct = MyStruct(prop_1: "hello", prop_2: 0, prop_3: 3.5, prop_4: true)
  myStruct.set(value: "bye", forKey: "prop_1")
  </code></pre>
  
  <p>Now the playground gives me an error because it is not clear what <em>set</em> function should be called. <strong>Playground execution failed: error: ProtocolsPlayground.playground:59:1: error: ambiguous use of 'set(value:forKey:)'
  myStruct.set(value: "bye", forKey: "prop_1")</strong>          </p>
  
  <p>This is clear but how can I achieve such function extension or is there a work around? Especially if the <em>Protocol_1</em> is not editable.</p>