Set.any should be a method

Although Set.any will always return the same element when not modifying
the set, that is an implementation detail. It should be a method.

Swift SVN r23697
This commit is contained in:
David Farler
2014-12-05 00:01:21 +00:00
parent e1dd3bad59
commit ad67a452dc
2 changed files with 7 additions and 7 deletions

View File

@@ -394,7 +394,7 @@ public struct _Set<T : Hashable> :
/// Remove a member from the set and return it if `count` > 0,
/// else return `nil`.
public mutating func removeAny() -> T? {
return (count > 0) ? remove(any!) : nil
return (count > 0) ? remove(any()!) : nil
}
/// The number of members in the set.
@@ -471,7 +471,7 @@ public struct _Set<T : Hashable> :
}
/// Return any member of the set if `count` > 0, else return `nil`.
public var any: T? {
public func any() -> T? {
return count > 0 ? self[startIndex] : .None
}