Swift Range Operators

Range Operator in Swift is a basic operator that is used to operate over a range. There are multiple types of range operators where we can include or exclude the upper range. Or we can start the range with some value or can end before some max value.

The range operators can be used with for loops, if conditions, switch conditions or even in array iteration. First, let to see a basic example of a range operator.

A basic range operator can be defined with … having a lower range value to the left side and upper range value to the right side of …

Now that we understood the very basic use cases of the range operators, let’s try to understand its types.

There are 3 types of range operators

  1. Closed Range Operator
  2. Half-Open Range Operator
  3. One-Sided Range Operator

Please continue reading at https://agrawalsuneet.github.io/blogs/swift-range-operators/

That’s all for now. You can read my other interesting blogs here or you can enjoy my games or apps listed here. Feel free to use my open-source Android components in your app listed here. Or drop an email, if you didn’t find what you are looking for and need some help.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store