# Extract Payload for enum cases having associated value

**URL:** <https://forums.swift.org/t/extract-payload-for-enum-cases-having-associated-value/27606>\
**Category:** Pitches\
**Tags:** enums, associatedvalue\
**Created:** [August 4, 2019, 4:16pm UTC](https://forums.swift.org/t/extract-payload-for-enum-cases-having-associated-value/27606 "2019-08-04T16:16:24Z")\
**Posts on this page:** 1\
**Showing post:** 128

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [August 13, 2019, 4:22pm UTC](https://forums.swift.org/t/extract-payload-for-enum-cases-having-associated-value/27606/128 "2019-08-13T16:22:27Z")

</div>

> [@ExFalsoQuodlibet](#):
>
> I just realized that instead of generating the computed properties for an enum, we could generate the keypaths, and use keypath member lookup to get the properties automatically 😐

Like below?

```swift
let result: Result<S, F> = ...
result.success // does not compile
result.failure // does not compile
let success = result[keypath: \.success]) // S?
let failure = result[keypath: \.failure]) // F?

```

This would be an interesting twist of [Automatically derive properties for enum cases - #5 by stephencelis](https://forums.swift.org/t/automatically-derive-properties-for-enum-cases/10843/5). No properties. Only key paths. But this is another pitch.

---

_[View the full topic](https://forums.swift.org/t/extract-payload-for-enum-cases-having-associated-value/27606)._
