struct

Array::View(T)

Inherits Comparable < Indexable < Enumerable < Iterable < Struct < Value < Object

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

Constructors

new(arr : Array(T))
Source

Instance methods

&(*args, **options)
Source
&(*args, **options, &)
Source
*(*args, **options)
Source
*(*args, **options, &)
Source
+(*args, **options)
Source
+(*args, **options, &)
Source
-(*args, **options)
Source
-(*args, **options, &)
Source
<=>(rhs : self) : Int32
Source
<=>(*args, **options)
Source
<=>(*args, **options, &)
Source
[](*args, **options)
Source
[](*args, **options, &)
Source
[]?(*args, **options)
Source
[]?(*args, **options, &)
Source
|(*args, **options)
Source
|(*args, **options, &)
Source
compact(*args, **options)
Source
compact(*args, **options, &)
Source
each_repeated_permutation(*args, **options)
Source
each_repeated_permutation(*args, **options, &)
Source
first(*args, **options)
Source
first(*args, **options, &)
Source
flatten(*args, **options)
Source
flatten(*args, **options, &)
Source
index(*args, **options)
Source
index(*args, **options, &)
Source
inspect(io : IO) : Nil

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)"
Source
last(*args, **options)
Source
last(*args, **options, &)
Source
map(*args, **options)
Source
map(*args, **options, &)
Source
map_with_index(*args, **options)
Source
map_with_index(*args, **options, &)
Source
reject(*args, **options)
Source
reject(*args, **options, &)
Source
remaining_capacity(*args, **options)
Source
remaining_capacity(*args, **options, &)
Source
repeated_permutations(*args, **options)
Source
repeated_permutations(*args, **options, &)
Source
reverse(*args, **options)
Source
reverse(*args, **options, &)
Source
rotate(*args, **options)
Source
rotate(*args, **options, &)
Source
sample(*args, **options)
Source
sample(*args, **options, &)
Source
select(*args, **options)
Source
select(*args, **options, &)
Source
shuffle(*args, **options)
Source
shuffle(*args, **options, &)
Source
size(*args, **options)
Source
size(*args, **options, &)
Source
skip(*args, **options)
Source
skip(*args, **options, &)
Source
skip_while(*args, **options)
Source
skip_while(*args, **options, &)
Source
sort(*args, **options)
Source
sort(*args, **options, &)
Source
sort_by(*args, **options)
Source
sort_by(*args, **options, &)
Source
take_while(*args, **options)
Source
take_while(*args, **options, &)
Source
to_a(*args, **options)
Source
to_a(*args, **options, &)
Source
to_s(*args, **options)
Source
to_s(*args, **options, &)
Source
transpose(*args, **options)
Source
transpose(*args, **options, &)
Source
uniq(*args, **options)
Source
uniq(*args, **options, &)
Source
unsafe_fetch(*args, **options)
Source
unsafe_fetch(*args, **options, &)
Source
unstable_sort(*args, **options)
Source
unstable_sort(*args, **options, &)
Source
unstable_sort_by(*args, **options)
Source
unstable_sort_by(*args, **options, &)
Source