Skip to content
Ruby

Array API Reference

Ruby's Array — an ordered, integer-indexed collection of any objects, with rich functional methods.

By EZ4Code Team

Array

Arrays are ordered, integer-indexed collections of any object.

Array#push(*objects) -> Array

Appends each given object to self. Returns self (with aliases <<).

Returns: Array

Array#pop -> object | nil

Removes and returns the last element of self, or nil if the array is empty.

Returns: Object | nil

Array#length -> Integer

Returns the number of elements in self. Alias: size.

Returns: Integer

Array#each {|item| block} -> Array

Calls the given block once for each element in self, passing that element as a parameter.

Returns: Array

Array#map {|item| block} -> Array

Returns a new array containing the values returned by the block for each element. Alias: collect.

Returns: Array

Array#select {|item| block} -> Array

Returns a new array containing all elements for which the block returns a truthy value.

Returns: Array

Array#include?(object) -> bool

Returns true if the given object is present in self, false otherwise.

Returns: Boolean

Array#join(separator=$,) -> String

Returns the concatenation of all elements converted to strings, joined by separator.

Returns: String

More Ruby API References