Previous episode: 11. More Filtering Operators
Next episode: 13. Conclusion
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
You've learned all about filtering operators so now it's time for a challenge. For this challenge, create a publisher that emits a collection of numbers from one to one hundred. Use filtering operators to skip the first 50 values emitted by the publisher, take the next 20 values from the publisher, only take even numbers. Pause the video, try coming up with the solution, and when you're ready, resume the video and I'll walk you through my solution. (upbeat music) Did you get the right sequence of numbers? Let's look at a solution. First making the publisher can be done just like the other examples in this part of the course using the collections built in publisher. To ignore the first 50 values from the publisher, you use drop first. Use the prefix operator to grab the next 20 values and be done. Next filter out the incoming values and accept only the ones that are even or divisible by two. Finally add the usual sync and store calls at the end. Run the playground and check the expected values. 52 through 70, just the even numbers. If you got this, great job.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.