Skip to content

Commit e036144

Browse files
committed
yet another useful utility
1 parent 05f5c9f commit e036144

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

bk2ch28AppendixB/bk2ch40AppendixB/ViewController.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ extension UIView {
174174
}
175175
}
176176

177-
// utility for shortening constraint creation
177+
// utility for shortening constraint creation, not in book
178178
// I'm not big on this kind of thing, but this is so common it seems to need something
179179

180180
extension UIView {
@@ -188,6 +188,13 @@ extension UIView {
188188
}
189189
}
190190

191+
// reverse of `contains`, not in book, but I'd much rather talk this way:
192+
193+
extension Equatable {
194+
func isMember<T>(of coll:T) -> Bool where T:Collection, T.Element == Self {
195+
return coll.contains(self)
196+
}
197+
}
191198

192199

193200
extension UIControl {

0 commit comments

Comments
 (0)