---
title: "Speaking of protocols"
slug: speaking-of-protocols
section: tech
date: 2015-06-19T17:21:00.000Z
canonical: https://roland.leth.ro/blog/tech/speaking-of-protocols
---

[Here](http://appventure.me/2015/06/17/swift-method-overloading-by-protocol/) is another nice read about protocols; method overriding, in particular. Some examples:

```swift
// Our generic class.
class DBStore<T> {
  
  func store(a: T) {
    store T
  }
  
}

protocol Storeable { }
protocol Interim { }

// Hello, generic Method Overloading by Protocol:
class DBStore<T> {
  
  func store<T: Storeable>(a: T) {
    // Store T.
  }
  
  func store<T: Interim>(a: T) {
    // Compress T.
  }
    
  // And more advanced:  
  func store<T: Storeable>(a: T) where T: Equatable {
    // Store T.
  }
  
}
```