Skip to content

Commit

Permalink
guard let instead of if let
Browse files Browse the repository at this point in the history
  • Loading branch information
tejassharma96 committed Jul 10, 2024
1 parent da7a3e4 commit da92e6a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Sources/Yams/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,11 @@ private extension Parser {
private func checkDuplicates(mappingKeys: [Node]) throws {
var duplicates: [String: [Node]] = [:]
for key in mappingKeys {
if let keyString = key.string {
if duplicates.keys.contains(keyString) {
duplicates[keyString]?.append(key)
} else {
duplicates[keyString] = [key]
}
guard let keyString = key.string else { continue }
if duplicates.keys.contains(keyString) {
duplicates[keyString]?.append(key)
} else {
duplicates[keyString] = [key]
}
}
duplicates = duplicates.filter { $1.count > 1 }
Expand Down

0 comments on commit da92e6a

Please sign in to comment.