Reactive Programming in iOS with Combine

Feb 4 2021 Swift 5.3, macOS 11.0, Xcode 12.2

Part 3: Combining Operators

17. Challenge: Append and Prepend

Lesson Complete

Play Next Lesson
Save for later
About this episode

See course reviews

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 16. Append Next episode: 18. More Combining Operators

This video was last updated on Feb 4 2021

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

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

You’ve learned all about Prepending and Appending operators - so now it’s time for a challenge. Back in the day, phone numbers used to be a lot easier to remember! 7 digits (in the United States, at least) was all you needed to remember to call your best friend. Now you need area codes, and if you’re calling a business, you’ll probably need to know a person’s extension, and if the number was long distance, you’d need to prepend a “1” in front of it. So for this challenge:

example(of: "Making Phone Numbers") {

  let phoneNumbersPublisher = ["123-4567"].publisher
  let areaCode = "410"
  let phoneExtension = "901"

    .prepend("1-", areaCode, "-")
    .append(" EXT ")
    .store(in: &subscriptions)