Created
November 5, 2017 04:32
-
-
Save 7gano/e3dbbb192bae6d87be754d6c8f2873df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: 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