newLiteList( item... )

Returns a new unmodifiable list, initialized with the specified items.

The list is implemented on top of an array, which has similar trade offs to newArrayList. Using an array means that randomly accessing individual items in the list is fast. As this is an unmodifiable list problems associated with adding items and increasing the capacity of the array are irrelevant.

A simple example is always useful, e.g. to construct a new list with a variety of items:

:-) newLiteList( 1,2,3,4, "hello", <xml /> );
There is 1 result
[1, 2, 3, 4, hello, <xml />]
      

You can also construct an unmodifiable list using the curly bracket notation, e.g.

:-) { 1,2,3,4, "hello", <xml /> };
There is 1 result
[1, 2, 3, 4, hello, <xml />]
      

and another example showing that lite lists are indeed unmodifiable:

:-) var aList = newLiteList( 1,2,3,4, "hello", <xml /> );
:-) aList[ 3 ] := "changed";


MISHAP  : Trying to update the index of an immutable list
BECAUSE : Immutable lists cannot be updated
KEY : 3
VALUE : changed
LIST : [1, 2, 3, 4, hello, <xml/>]
LINE NO. : 2
PHASE   : Evaluation
Trapped : org.millscript.millscript.Alert$EscapeException
Resetting input and resuming execution
      

Notes

If you know that you will need to modify the list, consider using newList, newArrayList or newLinkedList instead.