# How can I assign a default channel to another channel if it’s empty, while retaining its original content when it’s not empty, considering the default value is also a channel?

**URL:** <https://community.seqera.io/t/how-can-i-assign-a-default-channel-to-another-channel-if-it-s-empty-while-retaining-its-original-content-when-it-s-not-empty-considering-the-default-value-is-also-a-channel/1435>\
**Category:** Ask for help\
**Tags:** nextflow, platform\
**Created:** [November 17, 2024, 7:33am UTC](https://community.seqera.io/t/how-can-i-assign-a-default-channel-to-another-channel-if-it-s-empty-while-retaining-its-original-content-when-it-s-not-empty-considering-the-default-value-is-also-a-channel/1435 "2024-11-17T07:33:32Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [November 18, 2024, 10:26am UTC](https://community.seqera.io/t/how-can-i-assign-a-default-channel-to-another-channel-if-it-s-empty-while-retaining-its-original-content-when-it-s-not-empty-considering-the-default-value-is-also-a-channel/1435/3 "2024-11-18T10:26:17Z")

</div>

Here’s one way to solve the problem of if one channel is empty, use another one.

```nextflow
params.fill = false

workflow {
    ch_something = params.fill ? Channel.of(1..3) : Channel.empty()
    ch_backfill = Channel.of(4..6).toList()
    ch_something.collect().concat(ch_backfill).first().flatMap().view()
}

```

This uses the property that `collect` only emits a list if there’s something in the channel. Use `concat` to make sure the channel contents stay in order. and then use `first()` to take the first list from the concatenated channels. If `ch_something` is empty, there will be nothing, and the list from `ch_backfill` is taken.

---

_[View the full topic](https://community.seqera.io/t/how-can-i-assign-a-default-channel-to-another-channel-if-it-s-empty-while-retaining-its-original-content-when-it-s-not-empty-considering-the-default-value-is-also-a-channel/1435)._
