struct StaticArray(T, N)

Superclass hierarchy

Object
Value
StaticArray(T, N)

Included Modules

Enumerable(T)

Defined in:

Class Method Summary

Instance Method Summary

Class Method Detail

def self.new(value : T)

Creates a new static array filled with the given value.

StaticArray(Int32, 3).new(42) #=> [42, 42, 42]

def self.new(&block : Int32 -> T)

Creates a new static array and invokes the block once for each index of the array, assigning the block's value in that index.

StaticArray(Int32, 3).new { |i| i * 2 } #=> [0, 2, 4]

Instance Method Detail

def [](index : Int)

def []=(value : T)

def []=(index : Int, value : T)

def buffer

def count

def each(&block)

def length

def map!(&block)

def shuffle!

def size

def to_s(io : IO)

def to_slice

def to_unsafe

def update(index : Int, &block)

def values_at(*indexes : Int)

Returns a tuple populated with the elements at the given indexes. Raises if any index is invalid.

a = StaticArray(Int32, 4).new { |i| i + 1 }
a.values_at(0, 2) #=> {1, 3}