mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user