Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It confused me as well. "0.. is less than count"?


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)


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?


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.


Add spaces for clarity:

  0 ..< count
I think Swift programmers should adopt this style.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: