Skip to content
Discussion options

You must be logged in to vote

To that very use case, you could define

func identity<T>(_ value: T) -> T { value }

and replace observe: { $0 } with observe: identity. But it won't scale if you need to do anything else that can't be a simple key path expression.

(Curiously, observe: \.self also doesn't work because of a limitation in the Swift compiler.)

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@masurao3
Comment options

Answer selected by masurao3
Comment options

You must be logged in to vote
1 reply
@masurao3
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants