Reactive Programming in iOS with Combine

Feb 4 2021 · Swift 5.3, macOS 11.0, Xcode 12.2

Part 3: Combining Operators

20. Challenge: Advanced Combining

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 19. Operator Examples Next episode: 21. 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.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You've learned all about advanced combining operators, so now it's time for a challenge. For this challenge, you'll build upon the last challenge where you constructed some modern day phone numbers. This time however, the data is a bit more complex. In the starter project for this challenge, you'll find an array with a series of seven digit phone numbers represented as strings. You'll also find two other arrays. An area code array that goes before the number and an extension array that contains the string EXT followed by a number. The extension follows the phone number. To complete this challenge, take the seven digit number emitted by the publisher and turn it into a phone number of the form area code dash phone number, extension using what you've learned about advanced combining operators. Here's a hint. If you end up generating tuples, you can add some formatting by using the map operator and remembering that the first part of the tuple is dollar sign zero and the second part is dollar sign one. Pause the video, try to come up with a solution, and when you're ready, resume the video. (upbeat music) Were you able to pair the right area codes, phone numbers, and extensions together? Let's take a look at an example. On the area code publisher, use the zip operator to pair up area codes with phone numbers and then use the map operator to insert a hyphen between the elements. Use zip again to pair up the extensions with the phone numbers and use map to add a space between the elements. Finally use sink to print the values to the console and store the subscriptions as usual. Did you get this set of numbers to add to your phone book? If so, congrats. In the next episode we'll wrap up this part of the course so when you're ready, head on over to the final episode.