Swift function :
func sum(first: String, second: String) -> String { return "\((Int(first) ?? 0) + (Int(second) ?? 0))" }
And with a closure :
let _ = { (first: String, second: String) -> String in "\((Int(first) ?? 0) + (Int(second) ?? 0))" }
Isn't Int a sized integer? It won't work with numbers that don't fit in 64 bits (or 32 bits, if you compile it for 32 bit architectures)
Int
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Swift function :
And with a closure :
Isn't
Int
a sized integer? It won't work with numbers that don't fit in 64 bits (or 32 bits, if you compile it for 32 bit architectures)