Say I have a function that takes an Int
, but not just any Int
. It could be:
- Only natural numbers
Ints
from 2 to 200- etc
Assume that the number of valid values is too big to make the use of an Enum
that explicitly declares all of them a feasible approach.
Is there a way to declare a type that specifies a closed range in Swift?
I tried playing around with Range
, but it doesn't work as expected.