Skip to content

Commit

Permalink
Add proper documentation to Dictionary.filter(remaining: ...)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkenso committed Feb 26, 2024
1 parent e5a22dc commit 75b62ab
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/SpellbookFoundation/Common/Extensions - Collections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ extension Dictionary {
}

extension Dictionary {
/// Returns a new dictionary containing the key-value pairs of the dictionary
/// that satisfy the given predicate.
/// Collects unsatisfied elements into `remaining` dictionary.
///
/// - Parameter isIncluded: A closure that takes a key-value pair as its
/// argument and returns a Boolean value indicating whether the pair
/// should be included in the returned dictionary.
/// - Parameter remaining: A dictionary to collect elements that are
/// not included into returned dictionary.
/// - Returns: A dictionary of the key-value pairs that `isIncluded` allows.
public func filter(remaining: inout [Key: Value], _ isIncluded: (Element) throws -> Bool) rethrows -> [Key: Value] {
var filtered: [Key: Value] = [:]
for (key, value) in self {
Expand Down

0 comments on commit 75b62ab

Please sign in to comment.