Announcement

Collapse
No announcement yet.

Having a table brain fart....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Having a table brain fart....

    Hello,

    I'm trying to load a table with some data. I would call the table a "3D" table, for lack of better terms. I know I've done this before, but I'm missing something easy. I appreciate any help this morning.

    I create the table as so...

    my_table = {};

    then I want to load some data....

    my_table[1][1] = "apple";
    my_table[1][2] = "red";
    my_table[2][1] = "banana";
    my_table[2][2] = "yellow";
    etc...

    I'm getting an error, saying I'm trying to index a nil value.

    What am I missing?

    Thanks!

  • #2
    You could use
    Code:
    my_table = {};
    my_table[1] = {};
    my_table[1][1] = "apple";
    my_table[1][2] = "red";
    my_table[2] = {};
    my_table[2][1] = "banana";
    my_table[2][2] = "yellow";
    or
    Code:
    my_table = {{},{}};
    my_table[1][1] = "apple";
    my_table[1][2] = "red";
    my_table[2][1] = "banana";
    my_table[2][2] = "yellow";
    Ulrich

    Comment


    • #3
      Thanks Ulrich!

      I've never done it this way before. I guess I've always loaded tables in the past with the mysql plugin.

      Comment

      Working...
      X