class Godot::GodotArray(T)

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

Defined in:

libgodot/collections.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(ptr : Pointer(Void) = Pointer(Void).null) #

[View source]
def self.new(initial_items : Array(T)) #

[View source]

Class Method Detail

def self.from(items : Array(T)) : GodotArray(T) #

[View source]

Instance Method Detail

def <<(value : T) : self #

[View source]
def [](index : Int32) : T #

[View source]
def []=(index : Int32, value : T) : T #

[View source]
def []?(index : Int32) : T | Nil #

[View source]
def clear : Void #

[View source]
def each(&block : T -> Void) : Void #
Description copied from module Enumerable(T)

Must yield this collection's elements to the block.


[View source]
def empty? : Bool #
Description copied from module Enumerable(T)

Returns true if self does not contain any element.

([] of Int32).empty? # => true
([1]).empty?         # => false
[nil, false].empty?  # => false
  • #present? returns the inverse.

[View source]
def pop : T | Nil #

[View source]
def push(value : T) : self #

[View source]
def shift : T | Nil #

[View source]
def size : Int32 #
Description copied from module Enumerable(T)

Returns the number of elements in the collection.

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

[View source]
def to_a : Array(T) #
Description copied from module Enumerable(T)

Returns an Array with all the elements in the collection.

(1..5).to_a # => [1, 2, 3, 4, 5]

[View source]
def to_s(io : IO) : Void #
Description copied from class Reference

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>

[View source]