class Lua::Table

Included Modules

Defined in:

lua/object/table.cr

Instance Method Summary

Instance methods inherited from class Lua::Object

ref : Int32? ref, release(stack = @stack) release

Constructor methods inherited from class Lua::Object

new(stack : Stack, ref : Int32 | Nil) new

Macros inherited from class Lua::Object

methods methods

Instance Method Detail

def [](index) #

Returns the value at index or nil if there is no value at all.

t[2] = "test"
t[2] # => "test"

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

Sets a new value at index into a table.

t[3] = "test"
t[3] # => "test"

[View source]
def each(&) : Nil #

Implements Enumerable. Traverses a table in Lua stack using next.


[View source]
def each : Iterator #

Implements Iterable


[View source]
def next #

Implements Iterator. Traverses a table in Lua stack using next.


[View source]
def to_h #

Converts this table to Crystal hash.

t[1] = "a"
t["io"] = "b"
t[:gog] = "c"
t.to_h # => {"gog" => "c", 1.0 => "a", "io" => "b"}

[View source]
def to_s(io : IO) #

Represents table as a string.

t      # => [1.1, 2.1, 3.1]
t.to_s # => #3 {1.0 => 1.1, 2.0 => 2.1, 3.0 => 3.1}

[View source]