I'm conflicted here, because I really like the way array[try: 0]
reads, but I feel like if I saw that without knowing about this, I would immediately assume it's a version of the subscript that throws on invalid index. Instead, I agree with others in this thread who have stated this shouldn't be a subscript in the first place, since it can't be written to. The only reason left to make it a subscript would be similarity to the existing subscript.
My favorite spelling I've seen in here (and actually used in one of my own projects a while ago) is element(at:)
, but I would also be okay with something more verbose.
Another advantage of using a function for this (although this is bound to be fixed at some point in the future) is that you can alt-click the function in Xcode to get a documentation popup, telling you exactly what it does and how it differs from the subscript (if that's not clear already from the optional return type). The same is not yet possible for subscripts (even labeled ones).