Yes, that would be a simple way. But the question was asking for 2 specific types. So it depends on what Trialenzo intends to do exactly. The test would not be on nil value, but on the type of use to get the expected value in result: if useAsInt { result = Int(value) ?? 0 } else { result = value }
Yes, that would be a simple way. But the question was asking for 2 specific types. So it depends on what Trialenzo intends to do exactly. The test would not be on nil value, but on the type of use to get the expected value in result: if useAsInt { result = Int(value) ?? 0 } else { result = value }