Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Last active November 25, 2015 04:59
Show Gist options
  • Save jakecraige/945bd10d85ea401d6b70 to your computer and use it in GitHub Desktop.
Save jakecraige/945bd10d85ea401d6b70 to your computer and use it in GitHub Desktop.
Inferred typealias defined in protocol by implementing a function
protocol Action {
typealias StateType
func reduce(state: StateType) -> StateType
}
struct MyState { }
struct MyAction: Action {
// Note: We don't have to define the StateType alias, it infers it.
func reduce(state: MyState) -> MyState {
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment