class

Godot::GodotArray(T)

Inherits Enumerable < Reference < Object

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.

Constructors

new(ptr : Pointer(Void) = Pointer(Void).null)
Source
new(initial_items : Array(T))
Source

Class methods

from(items : Array(T)) : GodotArray(T)
Source

Instance methods

<<(value : T) : self
Source
[](index : Int32) : T
Source
[]=(index : Int32, value : T) : T
Source
[]?(index : Int32) : T | Nil
Source
clear
Source
each

Must yield this collection's elements to the block.

Source
empty?

Returns true if self does not contain any element.

([] of Int32).empty? # => true
([1]).empty?         # => false
[nil, false].empty?  # => false
  • #present? returns the inverse.
Source
push(value : T) : self
Source
shift
Source
size

Returns the number of elements in the collection.

[1, 2, 3, 4].size # => 4
Source
to_a

Returns an Array with all the elements in the collection.

(1..5).to_a # => [1, 2, 3, 4, 5]
Source
to_s(io : IO) : Void

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>
Source