I have tried code below.
My expectation is isDecimal("56.0")
should return true.
And isDecimal("56")
should return false,
also isDecimal(".")
should return false
but the function is returning true always. Please anyone help in this issue.
func isDecimal(str : String) -> Bool {
if let _ = Decimal(string: str) {
return true
}
return false
}
I have to verify there is always a integer after (dot). like 15.0 or 15.1. It should not be 15.a or 15. or 15.#