Why can't Swift infer base string with specific indexing string methods? -


here's don't understand: swift soooo @ "inferring things" ... yet, syntax of strings, say:

hello[hello.index(after: startindex)]   

requires second hello! no "other string" makes sense! why can't language updated work this?

hello[  .index(after: startindex) ] 

there times when must retype base string name 3 or 4 times in single line of code!

you this

let red: uicolor = uicolor.red 

that can written as

let red: uicolor = .red 

however in case .red type property of uicolor.

.red belong uicolor type, not particolar instance.

that's why can omit uicolor in second snippet. because swift knows .red inside uicolor class.

let's example

here

hello.index(after: hello.startindex) 

cannot become

hello.index(after: .startindex) 

because in case startindex not type property. it's property related specific value hello.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -