I find it somewhat cumbersome to rename a variable or constant when it's optionally bound. To avoid this, I was wondering if it's allowed to give the constant to which the value of the optional is bound the same name as the optional. Could this lead to problems or is this considered a bad practice? The compiler doesn't complain and the result is what I expect.
if let responseError = error {
...
}
It's easier (and possibly more elegant) to reuse the name of the optional as shown below. The downside is that you no longer have access to the optional in the
if
clause.if let error = error {
...
}