Created
January 14, 2018 06:06
-
-
Save es-kumagai/0f9fc59f513260e2c781646b47158808 to your computer and use it in GitHub Desktop.
こんな感じにしてみると、型推論のおかげで型がぜんぜん気にならなくなるから AnySequence で包んであげなくても気にならなそうね。 #CodePiece #minna_de_swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fibonacci = sequence(state: (current: 0, next: 1)) { state -> Int in | |
defer { | |
state = (current: state.next, next: state.current + state.next) | |
} | |
return state.current | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment