Skip to content

Commit

Permalink
Fix Swift 5.6 warning
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Feb 21, 2022
1 parent 8caadde commit 59de47c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
/.build
/.swiftpm
/.vscode
/Packages
/*.xcodeproj
/docs
Expand Down
4 changes: 3 additions & 1 deletion Sources/JMESPath/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,9 @@ struct SortFunction: JMESFunction {
case .array(let array):
let jmesArray = array.map { JMESVariable(from: $0) }
let sorted = jmesArray.sorted { $0.compare(.lessThan, value: $1) == true }
return .array(sorted.map { $0.collapse() })
// can use compact map here as we are guaranteed they won't be `nil` given the
// function signature requires numbers or strings
return .array(sorted.compactMap { $0.collapse() })
default:
preconditionFailure()
}
Expand Down

0 comments on commit 59de47c

Please sign in to comment.