Learning Swift by Wagner Andrew

Learning Swift by Wagner Andrew

Author:Wagner, Andrew
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2015-06-30T04:00:00+00:00


In this version of FibonacciSequence, we create a new generator every time generate is called, which takes a closure that does the same thing as our original FibonacciGenerator class does. We declare the values variable outside the closure so that we can use it to store the state between calls to the closure. If your generator is simple and doesn't require a complicated state, using the GenertorOf generic is a great way to go.

Now, let's use FibonacciSequence to solve the kind of math problem that computers are great at.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.