# Chapter 5 - Challenge - toArray creates Single\<\[Int\]\> that can't be subscribed to

**URL:** <https://forums.kodeco.com/t/chapter-5-challenge-toarray-creates-single-int-that-cant-be-subscribed-to/113862>\
**Category:** RxSwift\
**Created:** [July 3, 2020, 1:50am UTC](https://forums.kodeco.com/t/chapter-5-challenge-toarray-creates-single-int-that-cant-be-subscribed-to/113862 "2020-07-03T01:50:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![frankaceves](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/frankaceves/32/81494_2.png) [@frankaceves](https://forums.kodeco.com/u/frankaceves)\
**Post date:** [July 3, 2020, 1:50am UTC](https://forums.kodeco.com/t/chapter-5-challenge-toarray-creates-single-int-that-cant-be-subscribed-to/113862/1 "2020-07-03T01:50:14Z")

</div>

Picking back up from an [old post](https://forums.kodeco.com/t/chapter-5-challenge-toarray-problem/55184).

Not sure if this is going to be addressed in the book update this year, but the .toArray method creates a Single that can’t be observed.

```
func toArray() -> Single<[Int]>

```

_Summary_  
Converts an Observable into a Single that emits the whole sequence as a single array and then terminates.

The only thing I could come up with was adding .asObservable after .toArray, and then calling subscribe(onNext:).

```
let input = PublishSubject<Int>()
        input.skipWhile { (number) -> Bool in
            number == 0
        }
        .filter({ (number) -> Bool in
            number < 10 //must be single digit (1-9)
        })
        .take(10)
        .toArray()
        .asObservable()
        .subscribe(onNext: { (element) in
                //code...
         }
        .disposed(by: disposeBag)

```

Hope that helps anybody who was stuck on this challenge.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [March 20, 2021, 8:14pm UTC](https://forums.kodeco.com/t/chapter-5-challenge-toarray-creates-single-int-that-cant-be-subscribed-to/113862/3 "2021-03-20T20:14:21Z")

</div>



---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [March 20, 2021, 8:14pm UTC](https://forums.kodeco.com/t/chapter-5-challenge-toarray-creates-single-int-that-cant-be-subscribed-to/113862/4 "2021-03-20T20:14:49Z")

</div>

@scotteg Can you please help with this when you get a chance? Thank you - much appreciated! :]
