I'd like to append an s to the end of a string, if the value of a variable is > 1.
There are obviously several ways to accomplish this - for example:
if(points == 1) {
points_as_string = "1 Point"
} else {
points_as_string = "\(points) Points"
}
A shorter version could be:
points_as_string = (points == 1 ? "1 Point" : "\(points) Points")
An even shorter version would be:
points_as_string = "\(points) Point" + (points == 1 ? "" : "s")
Is it possible to write something even shorter than that, or is that as good as it gets?