class
Godot::GodotArray(T)
- Godot::GodotArray(T)
- Reference
- Object
Overview
A high-level Crystal wrapper around Godot's native Array type.
Named GodotArray to avoid shadowing Crystal's top-level ::Array.
Implements Enumerable and provides seamless conversion to/from Crystal Array.
Included Modules
- Enumerable(T)
Defined in:
libgodot/collections.crConstructors
Class Method Summary
Instance Method Summary
- #<<(value : T) : self
- #[](index : Int32) : T
- #[]=(index : Int32, value : T) : T
- #[]?(index : Int32) : T | Nil
- #clear : Void
-
#each(&block : T -> Void) : Void
Must yield this collection's elements to the block.
-
#empty? : Bool
Returns
trueifselfdoes not contain any element. - #pop : T | Nil
- #push(value : T) : self
- #shift : T | Nil
-
#size : Int32
Returns the number of elements in the collection.
-
#to_a : Array(T)
Returns an
Arraywith all the elements in the collection. -
#to_s(io : IO) : Void
Appends a short String representation of this object which includes its class name and its object address.
Constructor Detail
Class Method Detail
Instance Method Detail
Must yield this collection's elements to the block.
Returns true if self does not contain any element.
([] of Int32).empty? # => true
([1]).empty? # => false
[nil, false].empty? # => false
#present?returns the inverse.
Returns the number of elements in the collection.
[1, 2, 3, 4].size # => 4
Returns an Array with all the elements in the collection.
(1..5).to_a # => [1, 2, 3, 4, 5]
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>