Skip to content

Instantly share code, notes, and snippets.

@boraseoksoon
Created June 3, 2022 23:02
Show Gist options
  • Save boraseoksoon/192779cb192c2fb197807e3146a7cba8 to your computer and use it in GitHub Desktop.
Save boraseoksoon/192779cb192c2fb197807e3146a7cba8 to your computer and use it in GitHub Desktop.
if case let
indirect enum List<T> {
case empty
case node(T, List<T>)
var value: T? {
if case .node(let value, _) = self {
return value
} else {
return nil
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment