Skip to content

Instantly share code, notes, and snippets.

@iamchiwon
Created August 29, 2018 05:06
Show Gist options
  • Select an option

  • Save iamchiwon/560671de493be4fc354b393d59899d02 to your computer and use it in GitHub Desktop.

Select an option

Save iamchiwon/560671de493be4fc354b393d59899d02 to your computer and use it in GitHub Desktop.
현재 값을 넣고, 이전 값을 얻는다.
func lastValue<T>(_ initValue: T) -> (T) -> T {
var value: T = initValue
return { newValue in
let last = value
value = newValue
return last
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment