struct Array::View(T)
- Array::View(T)
- Struct
- Value
- Object
Overview
An ArrayView
is a read-only version of an Array
. This is useful to
give access to a non-modifiable array in a type-safe manner.
The functionality of ArrayView
is limited by design, as it just
delegates the methods defined by the Indexable
mixin to the enclosed
array.
arr = ArrayView.new([1, 2, 3, 4])
arr.size # => 4
arr[2] # => 3
arr.select &.even? # => [2, 4]
arr.select! &.even? # does not compile
arr.sort # does not compile
Included Modules
- Comparable(Indexable(T))
- Indexable(T)
Defined in:
views/array_view.crConstructors
Instance Method Summary
- #&(*args, **options)
- #&(*args, **options, &)
- #*(*args, **options)
- #*(*args, **options, &)
- #+(*args, **options)
- #+(*args, **options, &)
- #-(*args, **options)
- #-(*args, **options, &)
- #<=>(rhs : self) : Int32
- #<=>(*args, **options)
- #<=>(*args, **options, &)
- #[](*args, **options)
- #[](*args, **options, &)
- #[]?(*args, **options)
- #[]?(*args, **options, &)
- #|(*args, **options)
- #|(*args, **options, &)
- #compact(*args, **options)
- #compact(*args, **options, &)
- #each_repeated_permutation(*args, **options)
- #each_repeated_permutation(*args, **options, &)
- #first(*args, **options)
- #first(*args, **options, &)
- #flatten(*args, **options)
- #flatten(*args, **options, &)
- #index(*args, **options)
- #index(*args, **options, &)
-
#inspect(io : IO) : Nil
Appends this struct's name and instance variables names and values to the given IO.
- #last(*args, **options)
- #last(*args, **options, &)
- #map(*args, **options)
- #map(*args, **options, &)
- #map_with_index(*args, **options)
- #map_with_index(*args, **options, &)
- #reject(*args, **options)
- #reject(*args, **options, &)
- #remaining_capacity(*args, **options)
- #remaining_capacity(*args, **options, &)
- #repeated_permutations(*args, **options)
- #repeated_permutations(*args, **options, &)
- #reverse(*args, **options)
- #reverse(*args, **options, &)
- #rotate(*args, **options)
- #rotate(*args, **options, &)
- #sample(*args, **options)
- #sample(*args, **options, &)
- #select(*args, **options)
- #select(*args, **options, &)
- #shuffle(*args, **options)
- #shuffle(*args, **options, &)
- #size(*args, **options)
- #size(*args, **options, &)
- #skip(*args, **options)
- #skip(*args, **options, &)
- #skip_while(*args, **options)
- #skip_while(*args, **options, &)
- #sort(*args, **options)
- #sort(*args, **options, &)
- #sort_by(*args, **options)
- #sort_by(*args, **options, &)
- #take_while(*args, **options)
- #take_while(*args, **options, &)
- #to_a(*args, **options)
- #to_a(*args, **options, &)
- #to_s(*args, **options)
- #to_s(*args, **options, &)
- #transpose(*args, **options)
- #transpose(*args, **options, &)
- #uniq(*args, **options)
- #uniq(*args, **options, &)
- #unsafe_fetch(*args, **options)
- #unsafe_fetch(*args, **options, &)
- #unstable_sort(*args, **options)
- #unstable_sort(*args, **options, &)
- #unstable_sort_by(*args, **options)
- #unstable_sort_by(*args, **options, &)
Instance methods inherited from module Indexable(T)
[](index : Int, other : Int, *indexes : Int) : self[](indexes : Tuple) : Tuple
[](indexes : Indexable(Int)) : self
[](indexes : Enumerable(Int)) : self [], view : View(self, T) view
Constructor Detail
Instance Method Detail
def inspect(io : IO) : Nil
#
Description copied from struct Struct
Appends this struct's name and instance variables names and values to the given IO.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p1.to_s # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"