<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Ceylon (programming language) - Page 6 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=Ceylon_(programming_language)&amp;p=5">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Ceylon_%28programming_language%29&amp;p=7">3.Next</a>
</p>
<p>in a similar fashion to <a href="page.php?w=TypeScript">TypeScript</a>, <a href="page.php?w=Whiley_%28programming_language%29">Whiley</a> and <a href="page.php?w=FLOW_%28programming_language%29">FLOW</a>, which in fact, took the idea from Ceylon.</p>

<p>Union types, written <code>A|B</code>, allow a variable to have more than one type. The following example shows a Ceylon function which may take either an <a href="page.php?w=Integer_%28computer_science%29">integer</a> or a <a href="page.php?w=String_%28computer_science%29">string</a>:</p>

<p><syntaxhighlight lang="ceylon">shared void integerOrString(Integer|String input) {    if (is Integer input) {        print("Got the integer ``input``");    } else {        print("Got the string '``input``'");    }}</syntaxhighlight></p><p>
<a accesskey="1" href="page.php?w=Ceylon_(programming_language)&amp;p=5">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Ceylon_%28programming_language%29&amp;p=7">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
