module Array::MutableWrapper(T)
Overview
Wraps an Array
object. The including type will behave as an array,
where objects returned by methods will be wrapped as well if the
return type is the same as the original array.
class CustomArray(T)
include ArrayWrapper::Mutable(T)
end
arr = CustomArray.new([1, 2, 3, 4])
arr.size # => 4
arr[0]? # => 1
arr[6]? # => nil
arr.select(&.even?) # => [2, 4]
arr.select(&.even?).class # => CustomArray(Int32)
arr[0] = -1
arr[3] = -4
arr[0]? # => -1
arr[3]? # => -4
arr.select!(&.<(3))
arr # => [-1, 2, -4]
Included Modules
- Array::Wrapper(T)
- Indexable::Mutable(T)
Defined in:
views/array_wrapper_mutable.crInstance Method Summary
Macro Summary
Instance methods inherited from module Array::Wrapper(T)
&(*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, &) compact, each_repeated_permutation(*args, **options)
each_repeated_permutation(*args, **options, &) each_repeated_permutation, each_slice(n : Int, reuse : Array(T) | Bool = false, & : self -> ) : Nil each_slice, first(*args, **options)
first(*args, **options, &) first, flatten(*args, **options)
flatten(*args, **options, &) flatten, group_by(& : T -> U) : Hash(U, self) forall U group_by, index(*args, **options)
index(*args, **options, &) index, inspect(io : IO) : Nil inspect, last(*args, **options)
last(*args, **options, &) last, map(*args, **options)
map(*args, **options, &) map, map_with_index(*args, **options)
map_with_index(*args, **options, &) map_with_index, partition(& : T -> _) : Tuple(self, self) partition, reject(*args, **options)
reject(*args, **options, &) reject, remaining_capacity(*args, **options)
remaining_capacity(*args, **options, &) remaining_capacity, repeated_permutations(*args, **options)
repeated_permutations(*args, **options, &) repeated_permutations, reverse(*args, **options)
reverse(*args, **options, &) reverse, rotate(*args, **options)
rotate(*args, **options, &) rotate, sample(*args, **options)
sample(*args, **options, &) sample, select(*args, **options)
select(*args, **options, &) select, shuffle(*args, **options)
shuffle(*args, **options, &) shuffle, size(*args, **options)
size(*args, **options, &) size, skip(*args, **options)
skip(*args, **options, &) skip, skip_while(*args, **options)
skip_while(*args, **options, &) skip_while, sort(*args, **options)
sort(*args, **options, &) sort, sort_by(*args, **options)
sort_by(*args, **options, &) sort_by, take_while(*args, **options)
take_while(*args, **options, &) take_while, to_a : Array(T) to_a, to_s(*args, **options)
to_s(*args, **options, &) to_s, transpose(*args, **options)
transpose(*args, **options, &) transpose, uniq(*args, **options)
uniq(*args, **options, &) uniq, unsafe_fetch(*args, **options)
unsafe_fetch(*args, **options, &) unsafe_fetch, unstable_sort(*args, **options)
unstable_sort(*args, **options, &) unstable_sort, unstable_sort_by(*args, **options)
unstable_sort_by(*args, **options, &) unstable_sort_by
Constructor methods inherited from module Array::Wrapper(T)
new(wrapped : Array(T) = [] of T)
new
Instance methods inherited from module Wrapper(Array(T))
==(rhs : T(T)) : Bool==(rhs : self) : Bool ==, pretty_print(*args, **options)
pretty_print(*args, **options, &) pretty_print, to_s(*args, **options)
to_s(*args, **options, &) to_s, wrapped : T(T) wrapped
Constructor methods inherited from module Wrapper(Array(T))
new(wrapped : T(T) = T.new)
new
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
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