# Any thoughts on Ceylon-style union and intersection types?

**URL:** <https://discuss.kotlinlang.org/t/any-thoughts-on-ceylon-style-union-and-intersection-types/547>\
**Category:** Uncategorized\
**Created:** [October 24, 2012, 11:56pm UTC](https://discuss.kotlinlang.org/t/any-thoughts-on-ceylon-style-union-and-intersection-types/547 "2012-10-24T23:56:06Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![Ladicek](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ladicek/32/1554_2.png) [@Ladicek](https://discuss.kotlinlang.org/u/Ladicek)\
**Post date:** [July 17, 2014, 12:16pm UTC](https://discuss.kotlinlang.org/t/any-thoughts-on-ceylon-style-union-and-intersection-types/547/16 "2014-07-17T12:16:11Z")

</div>

Here's one case for intersection types: multiple upper bounds in generic functions (but I guess it applies to generic classes too). The documentation gives this example:

```
fun cloneWhenGreater<T : Comparable<T>>(list : List<T>, threshold : T) : List<T>
    where T : Cloneable {
  return list when {it > threshold} map {it.clone()}
}
```

Here, T has to be a subtype of Comparable\<T\> and it also has to be a subtype of Cloneable. Which in fact means that T has to be a subtype of an intersection type Comparable\<T\> & Cloneable, right? I think I'd like that more than the _where_ syntax, which feels more like a hack. But, if I remember correctly, there are other usecases for the _where_ clause, so this itself wouldn't be enough to get rid of it :-(

---

_[View the full topic](https://discuss.kotlinlang.org/t/any-thoughts-on-ceylon-style-union-and-intersection-types/547)._
