# Chapter 7 - Challenge Question

**URL:** <https://forums.kodeco.com/t/chapter-7-challenge-question/170758>\
**Category:** RxSwift\
**Created:** [May 10, 2022, 7:20am UTC](https://forums.kodeco.com/t/chapter-7-challenge-question/170758 "2022-05-10T07:20:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagjayo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jagjayo/32/110937_2.png) [@jagjayo](https://forums.kodeco.com/u/jagjayo)\
**Post date:** [May 10, 2022, 7:20am UTC](https://forums.kodeco.com/t/chapter-7-challenge-question/170758/1 "2022-05-10T07:20:22Z")

</div>

Hello I’m working on challenge(ing). I solved myself but have an unsolved question.

Here is my code. Added only code that i wrote.

```swift
let input = PublishSubject<String>()

// Add your code here
  input
    .skipWhile({ 
      print($0, $0 == "0")
      return $0 == 0 
    })
    .compactMap({ convert($0) })
    .take(10)
    .toArray()
    .map({ format($0) })
    .subscribe(onSuccess: {
      print($0)
    })
    .disposed(by: disposeBag)

```

2nd line’s `skipWhile()` is used meaning of skip before 0 includes 0. But here is the console.

```auto
--- Example of: Challenge 1 ---
 false
060-355-5121

```

In short, `skipWhile()` didn’t work after 1st Event emit.

I fixed it moving `skipWhile()` just below `compactMap()`.

What happend?? These 2-way using `skipWhile()` different???

```swift
input.skipWhile({$0 == "0"}).compactMap({convert($0)}) // Using 1
input.compactMap({convert($0)}).skipWhile({$0 == 0}) // Using 2

```

Have a nice day! Thanks!!

---

<div class="post-metadata">

**Author:** ![robertomachorro](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/robertomachorro/32/111603_2.png) [@robertomachorro](https://forums.kodeco.com/u/robertomachorro)\
**Post date:** [May 10, 2022, 6:29pm UTC](https://forums.kodeco.com/t/chapter-7-challenge-question/170758/2 "2022-05-10T18:29:20Z")

</div>

@scotteg @icanzilb any suggestions?

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [October 23, 2022, 11:21pm UTC](https://forums.kodeco.com/t/chapter-7-challenge-question/170758/3 "2022-10-23T23:21:00Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
