therein lies the problem.
that is a proposal, in a language design forum. It is couched in a highly inflected, coloquial version of english that is not taught or referenced ANYWHERE. In order to properly be able to understand Everything that is written there, one has to understand this Coloquial english, and in order to do that, You'd have to have been on the ground floor of the design and implementation of Swift in the first place. It lacks Any Kind of context, or bootstrapping cues.
And please... send up the flares and red flags as high as they will go... this is a global crit that Apple needs to hear and address post haste as a Unit: You have it Baked into the DNA of the Company now that You do not adequately document _ANYTHING_ on the developer's side of things, and when 3rd party devs do not learn or even know about such things, they do not adopt them... which is why the next killer app never arises. You are functionally killing your tech, by failing to create ocuments that make it a least "possible" to learn.
I did learn one thing from that link, that I did not know beforehand. But I am completely snowed under by something else, and as always there are no examples of something that should be relatively easy:
I have a variable:
let keyPath = \noWay.virtualFooBear
that I can then use like this:
let virtualVal = aWay[keyPath: keyPath]
I can then extend that into an Array (no example because it's dead obvious)
But when I try to expand to a Dictionary:
let thePaths = [ "v" : \noWay.virtualFooBear, "fooBear" : \noWay.fooBear ]
it does not work.
let virtualVal = aWay[keyPath: thePaths["v"]]
***** out with the error : Value of type 'noWay' has no subscripts
it's in a playground :
import UIKit
var str = "Hello, playground"
class noWay : NSObject {
var fooBear : String = "magical foo bear"
var virtualFooBear : String{
get { return "virtual" + fooBear }
set { fooBear = newValue }
}
}
let aWay = noWay()
aWay[keyPath: \noWay.virtualFooBear] = "boobooHiss"
let keyPath = \noWay.virtualFooBear
let thePaths = [ "v" : \noWay.virtualFooBear, "fooBear" : \noWay.fooBear ] //: [ String : KeyPath<noWay, String>]
let virtualVal = aWay[keyPath: thePaths["v"]]
using a dictionary is a good compromise stop-gap approach to trying to get into KeyPaths without throwing our hundreds of hours of work already done. But here's the thing: functionally, I'm not doing anything that should trigger an error, and if I am... the error is meaningless, and the proposal does not address anything to do with this error, so I cannot know how to fix it. I tried putting together a type for the dictionary hoping that it would silence the error... nope. I'm just guessing. "KeyPath<noWay, String>" doesn't actually mean anything to me. I've converted something I found online to the best approximation I could manage... And that's part of the overall problem, because Swift is a very opaque language when you get down to it. I'm experiencing Compoud levels of poorly documented or undocumented features in the Swift language that require me to learn things that are themselves poorly documented or not documented.
documentation is a deliberate step in the process of communicating with 3rd party developers, and Apple is not doing it. Granted: I am probably dumber than others, but I'm also smarter than others, and more willing to put in the effort. Don't reward me with pointlessly steep learning curves.