Skip to content

Commit 87912b3

Browse files
committed
Use if-let shorthands
1 parent f66aa7d commit 87912b3

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

Diff for: Sources/D2/D2.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct D2: ParsableCommand {
7070
let actualInitialPresence = (config?.setPresenceInitially ?? true) ? initialPresence ?? "\(commandPrefix)help" : nil
7171
let tokens = try DiskJsonSerializer().readJson(as: PlatformTokens.self, fromFile: "local/platformTokens.json")
7272

73-
if let config = config {
73+
if let config {
7474
log.info("\(config)")
7575
}
7676

Diff for: Sources/D2Commands/fun/PartyGameDatabase.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class PartyGameDatabase {
5454

5555
public func randomNhieStatement(category categoryToFilter: String? = nil) throws -> NeverHaveIEverStatement {
5656
var query = nhieStatements
57-
if let categoryToFilter = categoryToFilter {
57+
if let categoryToFilter {
5858
query = query.where(category == categoryToFilter)
5959
}
6060
guard let row = try db.prepare(query.order(Expression<Int>.random()).limit(1)).makeIterator().next() else {

Diff for: Sources/D2Commands/game/chess/ChessState.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public struct ChessState: GameState, FinitePossibleMoves {
2626
/// A very simple evaluation from the perspective of the current role
2727
/// that only takes the players' pieces' values into account.
2828
public var evaluation: Double {
29-
if let winner = winner {
29+
if let winner {
3030
return (winner == currentRole ? 1 : -1) * Double.infinity
31-
} else if let roleInCheck = roleInCheck {
31+
} else if let roleInCheck {
3232
return (roleInCheck == currentRole ? -1 : 1) * 200
3333
} else {
3434
let ourValue = Double(board.model.totalValue(for: currentRole))

Diff for: Sources/D2Commands/misc/MessageDatabase.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public class MessageDatabase: MarkovPredictor {
460460
public func generateMarkovTransitions(text: String? = nil) throws -> Int {
461461
var count = 0
462462

463-
if let text = text {
463+
if let text {
464464
let words = text.split(separator: " ").map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
465465
if words.count > markovOrder {
466466
for i in 0..<(words.count - markovOrder) {

Diff for: Sources/D2NetAPIs/mapquest/MapQuestStaticMap.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ public struct MapQuestStaticMap {
3939
URLQueryItem(name: "locations", value: pins.map(\.description).joined(separator: "||"))
4040
]
4141

42-
if let center = center {
42+
if let center {
4343
query.append(URLQueryItem(name: "center", value: "\(center.latitude),\(center.longitude)"))
4444
}
4545

46-
if let defaultMarker = defaultMarker {
46+
if let defaultMarker {
4747
query.append(URLQueryItem(name: "defaultMarker", value: defaultMarker))
4848
}
4949

0 commit comments

Comments
 (0)