[Swift] [Beginner]] About range operators

Encounter with range operator

I recently had an app I wanted to make and started studying swift, and the teaching materials explained the following about operators.

I've been working for about 4 years and experienced various languages, but honestly I was surprised because I had never used or heard of it. ~~ Just lack of knowledge ~~

How to use the range operator

It seems that swift is used like this ↓

sample.swift


var total = 0
for count in 0...5 {
  total += count
}
print(total)

As the name suggests, it is an operator that indicates a range. In this case, 0 to 5 are added and displayed. When I looked it up, swift couldn't write java or objective-c-like for statements from swift3.0, so I'd like to see it unless I write it with for-in. Reference article

Conclusion

You have to be able to use it ... ~~ (← range operator) ~~

Recommended Posts

[Swift] [Beginner]] About range operators
[Swift] About generics
[Swift] [Beginner] I searched a lot about #selector
[Swift] About enumeration types
[Swift] About protocol extension
[Beginner] About Active Storage
About [Cocoa] [Swift] AirPlay 2
[Beginner] About Rails Session
[Swift] Summary about Bool type
Explanation about Ruby Range object
[Swift] About asynchronous processing "Operation"
[Swift] I thought about compare
[Java beginner] About abstraction and interface
[Swift] "for-in statement" about iterative processing
Swift beginner Debugging memo with Xcode