The Ceylon language module containing the core types referred to in the language specification.
| Packages | |
| ceylon.language | The Ceylon language package. |
| ceylon.language.metamodel | |
The Ceylon language package.
| Attributes | |
| bottom | Source Code shared Bottom bottom A value that is assignable to any type, but that results in an exception when evaluated. This is most useful for generating members in an IDE. |
| equal | Source Code shared equal equal The value is exactly equal to the given value. By: Gavin |
| exhausted | Source Code shared exhausted exhausted A value that indicates that an See also: Iterator<Element> |
| false | Source Code shared false false A value representing falsity in Boolean logic. By: Gavin |
| infinity | Source Code shared Float infinity An instance of |
| language | Source Code shared language language Contains information about the language By: The Ceylon Team |
| larger | Source Code shared larger larger The value is larger than the given value. By: Gavin |
| null | Source Code shared null null The null value. By: Gavin |
| process | Source Code shared process process Represents the current process (instance of the virtual machine). By: Gavin, Tako |
| smaller | Source Code shared smaller smaller The value is smaller than the given value. By: Gavin |
| true | Source Code shared true true A value representing truth in Boolean logic. By: Gavin |
| Methods | |
| abstract | Source Code shared Nothing abstract() Annotation to mark a class as abstract.
|
| actual | Source Code shared Nothing actual() Annotation to mark a type or member as overriding an other type/member. |
| any | Source Code true if any of the given values is true, otherwise false See also: |
| array | Source Code Create an array containing the given elements. If no elements are provided, create an empty array of the given element type. |
| arrayOfNone | Source Code Create an empty array of the given element type. |
| arrayOfSize | Source Code Create an array of the specified size, populating every
index with the given element. If the specified size is
smaller than Parameters:
|
| arrayOfSome | Source Code Create a nonempty array with the elements of the given sequence. Parameters:
|
| bin | Source Code Annotation to specify a binary literal. |
| by | Source Code Annotation to specify API authors. |
| byDecreasing | Source Code A comparator which orders elements in decreasing order
according to the See also: byIncreasing |
| byIncreasing | Source Code A comparator which orders elements in increasing order
according to the See also: byDecreasing |
| byItem | Source Code shared Comparison? byItem<Item>(Comparison? comparing(Item x, Item y))(Entry<Key,Item> x, Entry<Key,Item> y) A comparator for See also: byKey |
| byKey | Source Code shared Comparison? byKey<Key>(Comparison? comparing(Key x, Key y))(Entry<Key,Item> x, Entry<Key,Item> y) A comparator for See also: byItem |
| className | Source Code Return the name of the concrete class of the given object. |
| coalesce | Source Code Return a sequence containing the given values which are not null. If there are no values which are not null, return an empty sequence. |
| combine | Source Code shared Iterable<Element> combine<Result, Element, OtherElement>(Result combination(Element element, OtherElement otherElement), Iterable<Element> elements, Iterable<Element> otherElements) Applies a function to each element of two By: Gavin, Enrique Zamudio |
| copyArray | Source Code shared Void copyArray<Element>(Array<Element> source, Array<Element> target, Integer from, Integer to, Integer length) Efficiently copy the elements of one array to another array. Parameters:
|
| count | Source Code A count of the number of |
| default | Source Code shared Nothing default() Annotation to mark a type or member whose implementation may be overridden
by subtypes. Non- |
| deprecated | Source Code Annotation to mark types or members which should not be used anymore. |
| doc | Source Code Annotation to specify API documentation on a type or member. |
| elements | Source Code The given elements (usually a comprehension), as an |
| emptyOrSingleton | Source Code shared Element[] emptyOrSingleton<Element>(Element? element) |
| entries | Source Code Produces a sequence of each index to element |
| equalTo | Source Code Returns a partial function that will compare an element to any other element and returns true if they're equal. This is useful in conjunction with methods that receive a predicate function. |
| every | Source Code true if every one of the given values is true, otherwise false. See also: |
| export | Source Code shared Nothing export() |
| first | Source Code shared Element? first<Element>(Element... elements) The first of the given elements (usually a comprehension), if any. |
| forItem | Source Code A function that returns the result of the given See also: forKey |
| forKey | Source Code A function that returns the result of the given See also: forItem |
| formal | Source Code shared Nothing formal() Annotation to mark a type or member whose implementation must be provided by subtypes. |
| greaterThan | Source Code Returns a partial function that will compare an element to any other element and returns true if the compared element is greater than its element. This is useful in conjunction with methods that receive a predicate function. |
| hex | Source Code Annotation to specify a hexadecimal literal. |
| identical | Source Code Determine if the arguments are identical. Equivalent to
See also: identityHash |
| identityHash | Source Code Return the system-defined identity hash value of the given value. This hash value is consistent with identity equality. See also: identical |
| join | Source Code Given a list of iterable objects, return a new sequence of all elements of the all given objects. If there are no arguments, or if none of the arguments contains any elements, return the empty sequence. See also: SequenceBuilder<Element> |
| largest | Source Code shared Element largest<Element>(Element x, Element y) Given two See also: Comparable<Other>, smallest, max |
| lessThan | Source Code Returns a partial function that will compare an element to any other element and returns true if the compared element is less than its element. This is useful in conjunction with methods that receive a predicate function. |
| license | Source Code Annotation to specify the URL of the license of a module or package. |
| max | Source Code shared Null|Value max<Value, Null>(Iterable<Element>&ContainerWithFirstElement<Element,Null> values) Given a nonempty sequence of See also: Comparable<Other>, min, largest |
| min | Source Code shared Null|Value min<Value, Null>(Iterable<Element>&ContainerWithFirstElement<Element,Null> values) Given a nonempty sequence of See also: Comparable<Other>, max, smallest |
| optional | Source Code shared Nothing optional() |
| parseFloat | Source Code The The syntax accepted by this method is the same as the
syntax for a |
| parseInteger | Source Code The The syntax accepted by this method is the same as the syntax for an
|
| Source Code Print a line to the standard output of the virtual
machine process, printing the given value's This method is a shortcut for: process.writeLine(line?.string else "«null»") and is intended mainly for debugging purposes. By: Gavin See also: | |
| see | Source Code Annotation to specify API references to other related API members. |
| shared | Source Code shared Nothing shared() Annotation to mark a type or member as shared.
Annotating them with |
| smallest | Source Code shared Element smallest<Element>(Element x, Element y) Given two See also: Comparable<Other>, largest, min |
| sort | Source Code shared Element[] sort<Element>(Element... elements) Sort a given elements, returning a new sequence. See also: Comparable<Other> |
| string | Source Code Create a new string containing the given characters. |
| sum | Source Code Given a nonempty sequence of See also: Summable<Other> |
| tagged | Source Code Annotation to categorize the API by tag. |
| throws | Source Code Annotation to mark methods as throwing an exception. |
| variable | Source Code shared Nothing variable() Annotation to mark an attribute as variable.
|
| zip | Source Code Given two sequences, form a new sequence consisting of all entries where, for any given index in the resulting sequence, the key of the entry is the element occurring at the same index in the first sequence, and the item is the element occurring at the same index in the second sequence. The length of the resulting sequence is the length of the shorter of the two given sequences. Thus: zip(xs,ys)[i]==xs[i]->ys[i] for every |
| Interfaces | |
| Binary | Source Code Abstraction of numeric types that consist in
a sequence of bits, like |
| Callable | Source Code A reference to a method or function. |
| Castable | Source Code Abstract supertype for types which can be automatically widened to a different type in numeric operator expressions. The type argument is a union of wider types to which the subtype can be cast. For example, |
| Category | Source Code shared Category Abstract supertype of objects that contain other
values, called elements, where it is possible to
efficiently determine if a given value is an element.
The if ("hello" in "hello world") { ... }
if (69 in 0..100) { ... }
if (key->value in { for (n in 0..100) n.string->n**2 }) { ... }
Ordinarily, |
| Cloneable | Source Code Abstract supertype of objects whose value can be cloned. |
| Closeable | Source Code shared Closeable Abstract supertype of types which may appear
as the expression type of a resource expression
in a |
| Collection | Source Code Represents an iterable collection of elements of finite
size. A All |
| Comparable | Source Code The general contract for values whose magnitude can be
compared. The total order of a type must be consistent with the definition of equality for the type. That is, there are three mutually exclusive possibilities:
|
| Container | Source Code shared Container Abstract supertype of objects which may or may not
contain one of more other values, called elements.
|
| ContainerWithFirstElement | Source Code Abstract supertype of containers which provide an
operation for accessing the first element, if any. A
container which may or may not be empty is a
|
| Correspondence | Source Code Abstract supertype of objects which associate values
with keys. The item corresponding to a given key may be obtained
from a value bg = settings["backgroundColor"] else white; The |
| Empty | Source Code shared Empty A sequence with no elements. The type of the expression
|
| Exponentiable | Source Code Abstraction of numeric types that may be raised to a power. Note that the type of the exponent may be different to the numeric type which can be exponentiated. |
| FixedSized | Source Code Represents a fixed-size collection which may or may not be empty. |
| Identifiable | Source Code shared Identifiable The abstract supertype of all types with a well-defined
notion of identity. Values of type |
| Integral | Source Code Abstraction of integral numeric types. That is, types
with no fractional part, including |
| Invertable | Source Code Abstraction of types which support a unary additive inversion operation. For a numeric type, this should return the negative of the argument value. Note that the type parameter of this interface is not restricted to be a self type, in order to accommodate the possibility of types whose additive inverse can only be expressed in terms of a wider type. |
| Iterable | Source Code Abstract supertype of containers whose elements may be iterated. An iterable container need not be finite, but its elements must at least be countable. There may not be a well-defined iteration order, and so the order of iterated elements may not be stable. An instance of for (c in "hello world") { ... }
Lazy operations are preferred, because they can be efficiently chained. For example: string.filter((Character c) c.letter).map((Character c) c.uppercased) is much less expensive than: string.select((Character c) c.letter).collect((Character c) c.uppercased) Furthermore, it is always easy to produce a new immutable iterable object given the view produced by a lazy operation. For example: { string.filter((Character c) c.letter).map((Character c) c.uppercased)... }
Lazy operations normally return an instance of
However, there are certain scenarios where an eager operation is more useful, more convenient, or no more expensive than a lazy operation, including:
Eager operations normally return a sequence. |
| Iterator | Source Code Produces elements of an |
| List | Source Code Represents a collection in which every element has a unique non-negative integer index. A Direct access to a list element by index produces a
value of optional type. The following idiom may be
used instead of upfront bounds-checking, as long as
the list element type is a non- value char = "hello world"[index];
if (exists char) { /*do something*/ }
else { /*out of bounds*/ }
To iterate the indexes of a for (i->char in "hello world".indexed) { ... }
|
| Map | Source Code Represents a collection which maps keys to items,
where a key can map to at most one item. Each such
mapping may be represented by an A The prescence of an entry in a map may be tested
using the if ("lang"->"en_AU" in settings) { ... }
The entries of the map may be iterated using for (key->item in settings) { ... }
The item for a key may be obtained using the item operator: String lang = settings["lang"] else "en_US"; |
| None | Source Code A fixed-size collection with no elements. |
| Number | Source Code shared Number Abstraction of numbers. Numeric operations are provided
by the subtype |
| Numeric | Source Code Abstraction of numeric types supporting addition,
subtraction, multiplication, and division, including
|
| Ordinal | Source Code Abstraction of ordinal types, that is, types with
successor and predecessor operations, including
|
| Ranged | Source Code Abstract supertype of ranged objects which map a range
of A span may be obtained from an instance of print("hello world"[0..5])
|
| Scalar | Source Code Abstraction of numeric types representing scalar
values, including |
| Sequence | Source Code A nonempty, immutable sequence of values. A sequence of values may be formed using braces: value worlds = { "hello", "world" };
value cubes = { for (n in 0..100) n**3 };
The union type Integer[] nums = ... ;
if (nonmpty nums) {
Integer first = nums.first;
Integer max = max(nums);
Sequence<Integer> squares = nums.collect((Integer i) i**2));
Sequence<Integer> sorted = nums.sort(byIncreasing((Integer i) i));
}
Operations like |
| Set | Source Code A collection of unique elements. A Sets may be the subject of the binary union,
intersection, exclusive union, and complement operators
|
| Sized | Source Code shared Sized Abstract supertype of |
| Some | Source Code A fixed-sized, non-empty collection. |
| Summable | Source Code Abstraction of types which support a binary addition operator. For numeric types, this is just familiar numeric addition. For strings, it is string concatenation. In general, the addition operation should be a binary associative operation. |
| Classes | |
| Array | Source Code A fixed-size array of elements. An array may have zero size (an empty array). Arrays are mutable. Any element of an array may be set to a new value. This class is provided primarily to support interoperation with Java, and for some performance-critical low-level programming tasks. |
| Boolean | Source Code shared abstract Boolean A type capable of representing the values true and false of Boolean logic. |
| ChainedIterator | Source Code An |
| Character | Source Code shared abstract Character A 32-bit Unicode character. |
| Comparison | Source Code shared abstract Comparison The result of a comparison between two |
| Entry | Source Code A pair containing a key and an associated value
called the item. Used primarily to represent the
elements of a |
| Finished | Source Code shared abstract Finished The type of the value that indicates that
an |
| Float | Source Code shared abstract Float A 64-bit floating point number. A |
| IdentifiableObject | Source Code shared abstract IdentifiableObject The default superclass when no superclass is explicitly
specified using |
| Integer | Source Code shared abstract Integer A 64-bit integer (or the closest approximation to a 64-bit integer provided by the underlying platform). |
| LazyList | Source Code An implementation of List that wraps an |
| LazyMap | Source Code A Map implementation that wraps an |
| LazySet | Source Code An implementation of Set that wraps an |
| Nothing | Source Code shared abstract Nothing The type of the |
| Object | Source Code shared abstract Object The abstract supertype of all types representing
definite values. Any two true==false
1=="hello world"
"hello"+ " " + "world"=="hello world"
Singleton("hello world")=={ "hello world" }
However, since |
| Range | Source Code Represents the range of totally ordered, ordinal values
generated by two endpoints of type A range may be produced using the for (i in min..max) { ... }
if (char in `A`..`Z`) { ... }
|
| SequenceAppender | Source Code This class is used for constructing a new nonempty
sequence by incrementally appending elements to an
existing nonempty sequence. The existing sequence is
not modified, since |
| SequenceBuilder | Source Code Since sequences are immutable, this class is used for constructing a new sequence by incrementally appending elements to the empty sequence. This class is mutable but threadsafe. |
| Singleton | Source Code A sequence with exactly one element. |
| String | Source Code shared abstract String A string of characters. Each character in the string is a 32-bit Unicode character. The internal UTF-16 encoding is hidden from clients. A string is a `w` in greeting "hello" in greeting Strings are summable: String greeting = "hello" + " " + "world"; They are efficiently iterable: for (char in "hello world") { ... }
They are value char = "hello world"[5]; They are ranged: String who = "hello world"[6...]; Note that since The string(for (s in "hello world") if (s.letter) s.uppercased) Since a |
| StringBuilder | Source Code shared StringBuilder Since strings are immutable, this class is used for constructing a string by incrementally appending characters to the empty string. This class is mutable but threadsafe. |
| Void | Source Code shared abstract Void The abstract supertype of all types. A value of type
Note that the type |
| equal | Source Code shared equal The value is exactly equal to the given value. |
| exhausted | Source Code shared exhausted A value that indicates that an |
| false | Source Code shared false A value representing falsity in Boolean logic. |
| language | Source Code shared language Contains information about the language |
| larger | Source Code shared larger The value is larger than the given value. |
| null | Source Code shared null The null value. |
| process | Source Code shared process Represents the current process (instance of the virtual machine). |
| smaller | Source Code shared smaller The value is smaller than the given value. |
| true | Source Code shared true A value representing truth in Boolean logic. |
| Exceptions | |
| Exception | Source Code shared Exception The supertype of all exceptions. A subclass represents a more specific kind of problem, and may define additional attributes which propagate information about problems of that kind. |
| NegativeNumberException | Source Code shared NegativeNumberException Thrown when a negative number is not allowed. |
| OverflowException | Source Code shared OverflowException Thrown when a mathematical operation caused a number to overflow from its bounds. |
| RecursiveInitializationException | Source Code Thrown when name could not be initialized due to recursive access during initialization. |