class
Lua::Table
- Lua::Table
- Lua::Object
- Reference
- Object
Included Modules
- Enumerable({Bool | Float64 | Lua::Object | Lua::Reference | String | Nil, Bool | Float64 | Lua::Object | Lua::Reference | String | Nil})
- Iterable({Bool | Float64 | Lua::Object | Lua::Reference | String | Nil, Bool | Float64 | Lua::Object | Lua::Reference | String | Nil})
Defined in:
lua/object/table.crInstance Method Summary
-
#[](index)
Returns the value at index or nil if there is no value at all.
-
#[]=(index, value)
Sets a new value at index into a table.
-
#each(&) : Nil
Implements Enumerable.
-
#each : Iterator
Implements Iterable
-
#next
Implements Iterator.
-
#to_h
Converts this table to Crystal hash.
-
#to_s(io : IO)
Represents table as a string.
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"
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"}
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}