# Cleaner way of writing functions for multiple types

**URL:** <https://forums.swift.org/t/cleaner-way-of-writing-functions-for-multiple-types/9874>\
**Category:** Pitches\
**Created:** [February 13, 2018, 1:53pm UTC](https://forums.swift.org/t/cleaner-way-of-writing-functions-for-multiple-types/9874 "2018-02-13T13:53:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![AlexanderM](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alexanderm/32/9781_2.png) [@AlexanderM](https://forums.swift.org/u/AlexanderM)\
**Post date:** [February 13, 2018, 2:11pm UTC](https://forums.swift.org/t/cleaner-way-of-writing-functions-for-multiple-types/9874/2 "2018-02-13T14:11:36Z")

</div>

Disjoint types add incredible complexity to the type system, with very little return. They don't add anything new, either. You could just make a new protocol, extend the desired types to conform to it, then take a value of that protocol type.

# [Commonly Rejected Changes](https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md#miscellaneous)

> [Disjunctions (logical ORs) in type constraints](https://forums.swift.org/t/returned-for-revision-se-0095-replace-protocol-p1-p2-syntax-with-any-p1-p2/2855): These include anonymous union-like types (e.g. (Int | String) for a type that can be inhabited by either an integer or a string). "[This type of constraint is] something that the type system cannot and should not support."

---

_[View the full topic](https://forums.swift.org/t/cleaner-way-of-writing-functions-for-multiple-types/9874)._
