Reputation: 365
I've this small piece of code. If the value is 0 then I want to go into if. This code never goes into if even if prints value 0. Can anyone point me what I'm doing wrong?
let value = (data?.object(forKey: "amount") as? String)!
print(String(describing: type(of: value)), value)
if value == "0" {
print("if")
}else{
print("else")
}
Print: String 0 else
Upvotes: 0
Views: 225
Reputation: 365
Somehow I figured out that the string was actually "0 " which was not obvious from print().
Upvotes: 1