Avatar
Avatar
Iceman
@swift-5.10.1 print([1, nil, 3, nil, 5].compactMap(\.self))
swift510 BOT 2/14/2024 8:02 AM
exit status: 1 with <stdin>:1:38: error: cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int?) throws -> ElementOfResult?' print([1, nil, 3, nil, 5].compactMap(\.self)) ^ <stdin>:1:27: error: generic parameter 'ElementOfResult' could not be inferred print([1, nil, 3, nil, 5].compactMap(\.self)) ^ Swift.Sequence:2:28: note: in call to function 'compactMap' @inlinable public func compactMap<ElementOfResult>(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] ^ <stdin>:1:38: error: cannot infer key path type from context; consider explicitly specifying a root type print([1, nil, 3, nil, 5].compactMap(\.self)) ^ <#Root#>