Skip to content

Commit

Permalink
Update PersianSwear.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
amirshnll committed Jun 7, 2023
1 parent c2455c4 commit 3c86309
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions PersianSwear.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import Foundation

final class PersianSwear {
private typealias Words = HashSet<String>
private typealias Words = Set<String>

static let shared = PersianSwear(words: [])

private(set) var words: Words = HashSet<String>()
private(set) var words: Words = hSet<String>()

init(words: Words = HashSet<String>()) {
init(words: Words = Set<String>()) {
self.words = words
}

convenience init(words: [String] = []) {
self.init(words: HashSet(words))
self.init(words: Set(words))
}

func loadWords(using loader: PersianSwearDataLoader, completion: @escaping (Result<Words, Error>) -> Void) {
Expand All @@ -38,7 +38,7 @@ final class PersianSwear {
}

func addWords(_ words: [String]) {
addWords(HashSet(words))
addWords(Set(words))
}

func removeWord(_ word: String) {
Expand All @@ -50,7 +50,7 @@ final class PersianSwear {
}

func removeWords(_ words: [String]) {
removeWords(HashSet(words))
removeWords(Set(words))
}

func isBadWord(_ word: String) -> Bool {
Expand Down Expand Up @@ -103,7 +103,7 @@ class GithubPersianSwearDataLoader: PersianSwearDataLoader {

do {
let model = try JSONDecoder().decode(Model.self, from: data)
completion(.success(HashSet(model.word)))
completion(.success(Set(model.word)))
} catch {
completion(.failure(error))
}
Expand Down

0 comments on commit 3c86309

Please sign in to comment.