# The List Class

This page details the properties of the List class. To learn about what the List class is and how you would use it, read about them in this tutorial.

Please note that this reference is elliptical because we autogenerated it. Consider it not a lesson but a reference.

## Instance Rules

### * n

an list of n instances of the receiver concatenated together### +

concatenation### [i]

returns the ith element of the receiver, where 0 is the first element of the list; negative indices count from the end.### .length

one greater than the index of the element with the highest index (not necessarily the same as count)### .count

the number of elements the programmer explicitly set (not necessarily the same as length)### .empty?

(as in Scheme, Ruby)### .contains?[x]

Ruby### .delete-at![i]

deletes the ith element of the receiver### .insert![i, x, n=1]

inserts x n times at i### .pop!

Removes and returns the last element of the list (as in JavaScript).### .push!

returns the receiver (as in Ruby)### .shift!

(as in JavaScript)### .unshift!

returns the receiver (as in JavaScript)### .index-of[x]

returns the index of the first occurance of x in the receiver.### .last-index-of[x]

Like .index-of, but from the end of the list; returns the index of the last occurance of x in the receiver.### .join[s]

calls .to-string on each element of the list, intersperses s between each element, and concatenates the entire result into a string. (as in JavaScript)### .sort![]

sorts a list of integers (as in JavaScript)### .sort![f]

takes a funject that returns numbers; an element with a number higher than another should appear after it (as in JavaScript)### .map![f, [ or ]]

copies the list before iterating; if given an index or range, maps over only those elements
### .pluck![key]

(as in Underscore.js)### .invoke![key]

(as in Underscore.js)### .filter![f]

returns a list containing only the elements for which f[e] is true### .reject![f]

The opposite of .filter; returns a list containing only the elements for which f[e] is false### .reduce

(as in JavaScript)### .reduce-right

(as in JavaScript)### .every[f]

.every returns true if for every element x in the receiver, f[x] is true.every copies the list before iterating

### .any[f]

.any returns true if for any element x in the receiver, f[x] is true.compare to .every[f]

.any copies the list before iterating