CSAllenISDClassroom / sudokuserver-acid-dragons-1

sudokuserver-acid-dragons-1 created by GitHub Classroom
1 stars 1 forks source link

Warning issued by compiler #31

Closed agarmu closed 3 years ago

agarmu commented 3 years ago

Upon compilation, the following warning is issued by the Swift Compiler:

sudokuserver-acid-dragons-1/Sources/App/routes.swift:86:19: warning: explicitly specified type 'Int?' adds an additional level of optional to the initializer, making the optional check always succeed
            guard let value : Int? = try JSONDecoder().decode(UserInput.self, from: jsonData).value else {
                  ^           ~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              Int
pkfire583 commented 3 years ago

Get rid of optional check. By changing the guard statement into a regular optional Int, error disappears. (guard let value : Int? = try JSONDecoder().decode(UserInput.self, from: jsonData).value else{ ) -> (let value : Int? = try JSONDecoder().decode(UserInput.self, from: jsonData).value)