Re:Swift is like Kotlin
by seanwilson on Thursday May 18, 2017 @12:11AM
(#14364748)
It confused me as well. "0.. is less than count"?
[ Parent
| on HN ]
Personally, I find that just having "0..count" requires a bit of thinking on my part trying to decide if it's inclusive or not.
"0..<count" instantly tells me that it's not including value, and follows the matematical interval notification [0..count] vs [0..count)
Re:Swift is like Kotlin
by seanwilson on Thursday May 18, 2017 @02:16AM
(#14365172)
I'd prefer 0..count or 0..(count - 1) then.
I believe it was discussed in Swift Evolution, not confusing.
0...1 //0 to 1
Note: triple dot. 0..2 //error: repl.swift:1:2: error: use of unresolved operator '..'
0..<1 //0 to <1".." has a meaning – why are you leaving it out of the translation?
Re:Swift is like Kotlin
by seanwilson on Thursday May 18, 2017 @02:17AM
(#14365175)
I'd usually use ".." in the context of e.g. "2..3" to express a range but "<" to express a condition so I don't find it natural.