# Use-site variance: is in and out a sugar for where?

**URL:** <https://discuss.kotlinlang.org/t/use-site-variance-is-in-and-out-a-sugar-for-where/18936>\
**Category:** Uncategorized\
**Created:** [August 27, 2020, 9:13am UTC](https://discuss.kotlinlang.org/t/use-site-variance-is-in-and-out-a-sugar-for-where/18936 "2020-08-27T09:13:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishitatsuyuki](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ishitatsuyuki/32/7881_2.png) [@ishitatsuyuki](https://discuss.kotlinlang.org/u/ishitatsuyuki)\
**Post date:** [August 27, 2020, 9:13am UTC](https://discuss.kotlinlang.org/t/use-site-variance-is-in-and-out-a-sugar-for-where/18936/1 "2020-08-27T09:13:31Z")

</div>

I’m wondering if `in` and `out` can always be replaced with `where` in use-site variance. For example, it seems to me that the following functions are all considered identical.

```auto
fun <A,B> f(a: Array<A>, b: Array<B>) where A: B {}
fun <A> g(a: Array<A>, b: Array<in Int>) {}
fun <A> h(a: Array<out A>, b: Array<A>) {}

```

Given this, can one say that `in` and `out` can be desugared into `where`? (I just want to confirm that my understanding of type system is correct, no intention to compare between ways to write the conditions.)

---

<div class="post-metadata">

**Author:** ![arocnies](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/arocnies/32/5143_2.png) [@arocnies](https://discuss.kotlinlang.org/u/arocnies)\
**Post date:** [September 2, 2020, 2:06pm UTC](https://discuss.kotlinlang.org/t/use-site-variance-is-in-and-out-a-sugar-for-where/18936/2 "2020-09-02T14:06:59Z")

</div>

I’m surprised to say I almost asked “Which language uses ‘where’?” I guess I forgot that Kotlin has a where-clause.

From [the docs](https://kotlinlang.org/docs/reference/generics.html#generic-constraints), the where-clause is used when there is more than one upper bound.

However, having `T` be required to extend from more than one type does not affect the variance–you’d still have to use `in T` and `out T` with your where-clause.
