# SLC: make .to(IArray) work for collections

**URL:** <https://contributors.scala-lang.org/t/slc-make-to-iarray-work-for-collections/7466>\
**Category:** Scala Standard Library\
**Created:** [June 5, 2026, 1:52pm UTC](https://contributors.scala-lang.org/t/slc-make-to-iarray-work-for-collections/7466 "2026-06-05T13:52:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bishabosha](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/bishabosha/32/3101_2.png) [@bishabosha](https://contributors.scala-lang.org/u/bishabosha)\
**Post date:** [June 5, 2026, 1:52pm UTC](https://contributors.scala-lang.org/t/slc-make-to-iarray-work-for-collections/7466/1 "2026-06-05T13:52:55Z")

</div>

If you want to convert data to an IArray, code like the following is currently not possible:

```scala
def example = collection.view.map(_ * 2).to(IArray)

```

currently, you can only use the direct factory methods:

- `IArray.from(collection)`
- `IArray(collection*)`

implementation here: [Add implicit conversion from IArray.type to Factory by bishabosha · Pull Request #24675 · scala/scala3 · GitHub](https://github.com/scala/scala3/pull/24675)

question remains if this is good enough, or if we want to also add `.toIArray` variants wherever `.toArray` exists. - perhaps this is overkill if in a couple years `separationChecking` can land with frozen mutability for `Array` (making `IArray` redundant)

---

<div class="post-metadata">

**Author:** ![SethTisue](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/sethtisue/32/3185_2.png) [@SethTisue](https://contributors.scala-lang.org/u/SethTisue)\
**Post date:** [June 5, 2026, 3:19pm UTC](https://contributors.scala-lang.org/t/slc-make-to-iarray-work-for-collections/7466/2 "2026-06-05T15:19:16Z")

</div>

I think adding `toIArray` would be overkill even if you don’t make the separation checking argument. `to(IArray)` is fine.

We have very few such methods that name specific collection implementations — just `toVector`, `toList`, and `toArray`. All of them are technically redundant with their `.to(X)` forms, and it’s possible we wouldn’t even introduce any of them today if they didn’t already exist. So let’s not add more, especially since I don’t see `IArray` being used a ton in the wild.

---

<div class="post-metadata">

**Author:** ![bjornregnell](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/bjornregnell/32/1855_2.png) [@bjornregnell](https://contributors.scala-lang.org/u/bjornregnell)\
**Post date:** [June 8, 2026, 4:17pm UTC](https://contributors.scala-lang.org/t/slc-make-to-iarray-work-for-collections/7466/3 "2026-06-08T16:17:06Z")

</div>

Well, `.to(X)` might need an import of X (or a longer a.b.c.X path) depending on what’s “automatically” available so `.toX` is more convenient and more discoverable…

---

<div class="post-metadata">

**Author:** ![bishabosha](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/bishabosha/32/3101_2.png) [@bishabosha](https://contributors.scala-lang.org/u/bishabosha)\
**Post date:** [June 9, 2026, 8:20pm UTC](https://contributors.scala-lang.org/t/slc-make-to-iarray-work-for-collections/7466/4 "2026-06-09T20:20:58Z")

</div>

IArray is in scala package so is automatically in scope (for typical users anyway)
