Type Hierarchy:
Satisfied Interfaces: Category, Cloneable<List<Element>>, Collection<Element>, Correspondence<Integer,Element>, Iterable<Element,Nothing>, List<Element>, Ranged<Integer,List<Element>>, Sequence<Element>, Sequential<Element>

A sequence with exactly one element, which may be null.

Initializer
Singleton(Element element)
Attributes
cloneSource Code
shared actual Singleton<Element> clone

Returns a Singleton with the same element.

Refined declaration: clone
coalescedSource Code

Returns the Singleton itself, or empty

Refined declaration: coalesced
firstSource Code
shared actual Element first

Returns the element contained in this Singleton.

Refined declaration: first
hashSource Code
shared actual Integer hash

The hash value of the value, which allows the value to be an element of a hash-based set or key of a hash-based map. Implementations must respect the constraint that if x==y then x.hash==y.hash.

Refined declaration: hash
lastSource Code
shared actual Element last

Returns the element contained in this Singleton.

Refined declaration: last
lastIndexSource Code
shared actual Integer lastIndex

Returns 0.

Refined declaration: lastIndex
restSource Code
shared actual [] rest

Returns Empty.

Refined declaration: rest
reversedSource Code
shared actual Singleton<Element> reversed

Return this singleton.

Refined declaration: reversed
sizeSource Code
shared actual Integer size

Returns 1.

Refined declaration: size
stringSource Code
shared actual String string

A developer-friendly string representing the instance. Concatenates the name of the concrete class of the instance with the hash of the instance. Subclasses are encouraged to refine this implementation to produce a more meaningful representation.

Refined declaration: string
Inherited Attributes
Attributes inherited from: Cloneable<Clone>
Attributes inherited from: Collection<Element>
Attributes inherited from: Correspondence<Key,Item>
Attributes inherited from: Iterable<Element,Absent>
Attributes inherited from: List<Element>
Attributes inherited from: [Element+]
Attributes inherited from: Element[]
Methods
anySource Code
shared actual Boolean any(Boolean selecting(Element e))

Return true if at least one element satisfies the predicate function.

Refined declaration: any
containsSource Code
shared actual Boolean contains(Object element)

Returns true if the specified element is this Singleton's element.

Refined declaration: contains
countSource Code
shared actual Integer count(Boolean selecting(Element element))

Returns 1 if this Singleton's element satisfies the predicate, or 0 otherwise.

Refined declaration: count
equalsSource Code
shared actual Boolean equals(Object that)

A Singleton can be equal to another List if that List has only one element which is equal to this Singleton's element.

Refined declaration: equals
everySource Code
shared actual Boolean every(Boolean selecting(Element e))

Return true if all elements satisfy the predicate function.

Refined declaration: every
filterSource Code
shared actual Singleton<Element>|[] filter(Boolean selecting(Element e))

An Iterable containing the elements of this container that satisfy the given predicate.

Refined declaration: filter
findSource Code
shared actual Element? find(Boolean selecting(Element e))

The first element which satisfies the given predicate, if any, or null otherwise.

Refined declaration: find
findLastSource Code
shared actual default Element? findLast(Boolean selecting(Element elem))

The last element which satisfies the given predicate, if any, or null otherwise.

Refined declaration: findLast
foldSource Code
shared actual Result fold<Result>(Result initial, Result accumulating(Result partial, Element e))

The result of applying the accumulating function to each element of this container in turn.

Refined declaration: fold
getSource Code

Returns the contained element, if the specified index is 0.

Refined declaration: get
iteratorSource Code
shared actual default Iterator<Element> iterator()

An iterator for the elements belonging to this container.

Refined declaration: iterator
mapSource Code
shared actual [Result+] map<Result>(Result selecting(Element e))

An Iterable containing the results of applying the given mapping to the elements of to this container.

Refined declaration: map
segmentSource Code
shared actual []|Singleton<Element> segment(Integer from, Integer length)

Returns a Singleton if the given starting index is 0 and the given length is greater than 0. Otherwise, returns an instance of Empty.

Refined declaration: segment
skippingSource Code
shared actual Singleton<Element>|[] skipping(Integer skip)

Produce an Iterable containing the elements of this iterable object, after skipping the first skip elements. If this iterable object does not contain more elements than the specified number of elements, the Iterable contains no elements.

Refined declaration: skipping
sortSource Code
shared actual Singleton<Element> sort(Comparison comparing(Element a, Element b))

A sequence containing the elements of this container, sorted according to a function imposing a partial order upon the elements.

For convenience, the functions byIncreasing() and byDecreasing() produce a suitable comparison function:

"Hello World!".sort(byIncreasing((Character c) => c.lowercased))

This operation is eager by nature.

Refined declaration: sort
spanSource Code
shared actual []|Singleton<Element> span(Integer from, Integer to)

Returns a Singleton if the given starting index is 0. Otherwise, returns an instance of Empty.

Refined declaration: span
spanFromSource Code
shared actual []|Singleton<Element> spanFrom(Integer from)

Obtain a span containing the mapped values between the starting index and the end of the receiver.

Refined declaration: spanFrom
spanToSource Code
shared actual []|Singleton<Element> spanTo(Integer to)

Obtain a span containing the mapped values between the start of the receiver and the end index.

Refined declaration: spanTo
takingSource Code
shared actual Singleton<Element>|[] taking(Integer take)

Produce an Iterable containing the first take elements of this iterable object. If the specified number of elements is larger than the number of elements of this iterable object, the Iterable contains the same elements as this iterable object.

Refined declaration: taking
Inherited Methods
Methods inherited from: Category
Methods inherited from: Correspondence<Key,Item>
Methods inherited from: Iterable<Element,Absent>
Methods inherited from: List<Element>
Methods inherited from: Ranged<Index,Span>