young
(rtSwift)
1
So I was trying out the code from here and got error:
error: cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Bool) -> Bool'**
error: cannot infer key path type from context; consider explicitly specifying a root type
.filter(.self)
^
<#Root#>
My Playground
let (switch1, switch2, switch3, switch4) = (true, true, false, false)
let switches = [switch1, switch2, switch3, switch4]
let isOn = !switches
.lazy
.filter(\.self) // error here
.count
.isMultiple(of: 2)
It’s a known bug: SR-12897
1 Like
AlexanderM
(Alexander Momchilov)
3
Just use .filter { $0 } for now.
1 Like