The type of Collection created is based on the input.
If an Collection, that same Collection.
If an Array-like, an Collection.Indexed.
If an Object with an Iterator defined, an Collection.Indexed.
If an Object, an Collection.Keyed.
This methods forces the conversion of Objects and Strings to Collections.
If you want to ensure that a Collection of one item is returned, use
Seq.of.
Note: An Iterator itself will be treated as an object, becoming a Seq.Keyed,
which is usually not what you want. You should turn your Iterator Object into
an iterable object by defining a Symbol.iterator (or @@iterator) method which
returns this.
Note: Collection is a conversion function and not a class, and does not
use the new keyword during construction.
Creates a Collection.
The type of Collection created is based on the input.
Collection
, that sameCollection
.Collection.Indexed
.Collection.Indexed
.Collection.Keyed
.This methods forces the conversion of Objects and Strings to Collections. If you want to ensure that a Collection of one item is returned, use
Seq.of
.Note: An Iterator itself will be treated as an object, becoming a
Seq.Keyed
, which is usually not what you want. You should turn your Iterator Object into an iterable object by defining a Symbol.iterator (or @@iterator) method which returnsthis
.Note:
Collection
is a conversion function and not a class, and does not use thenew
keyword during construction.