So I'm basically struggling with understanding of why this not working. As I understood from this thread this code
let users = [User]()
users.map(\.name)
Translates right too
users.map { $0[keyPath: \.name] }
But this code not working
users.map(\.self)
While this code is perfectly fine
users.map { $0[keyPath: \.self] }
xwu
(Xiaodi Wu)
2
That seems like a bug: the proposal itself shows [1, nil, 3, nil, 5].compactMap(\.self)
as an example of a supported self
key path.
1 Like
Yep, for me it's also looks like a bug 
I reported both of these bugs awhile back if you want to follow them:
https://bugs.swift.org/browse/SR-12387
2 Likes
Oh, didn't see that, thanks!