Skip to content

Instantly share code, notes, and snippets.

@7gano
Created November 5, 2017 04:32
Show Gist options
  • Save 7gano/e3dbbb192bae6d87be754d6c8f2873df to your computer and use it in GitHub Desktop.
Save 7gano/e3dbbb192bae6d87be754d6c8f2873df to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
class Hoge: Comparable, Hashable {
let text:String
init(text:String) {
self.text = text
}
static func ==(x: Hoge, y: Hoge) -> Bool {
return x.text == y.text
}
static func <(x: Hoge, y: Hoge) -> Bool {
return x.text > y.text
}
var hashValue: Int {
return text.hashValue
}
}
let a = Hoge(text:"ほげ")
let b = Hoge(text:"ほげ")
a == b
var set:Set<Hoge> = []
set.insert(a)
set.insert(b)
set.count //1!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment