Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6646143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:22:50+00:00 2026-05-26T00:22:50+00:00

I quickly had to debug something, and wrote following function: function dumpTable(t) for i,v

  • 0

I quickly had to debug something, and wrote following function:

function dumpTable(t)
    for i,v in pairs(t) do
        if type(v) == "table" then
            dumpTable(v)
        else
            print(i..":", v)
        end
    end
end

Now, for some reason

dumpTable({[1]="hello??", [2]="two", {[132]="something", [3.2]="else"}})

outputs

132:    something
3.2:    else
2:  two

notice how the first string is missing? But if I change its key..

dumpTable({["one"]="hello??", [2]="two", {[132]="something", [3.2]="else"}})

it outputs

132:    something
3.2:    else
one:    hello??
2:  two

This is so unintuitive I almost feel like making an idiot of myself not seeing the mistake..

(btw. I do know that my function will overflow the stack if the table contains a recursive reference, going to fix that later)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:22:50+00:00Added an answer on May 26, 2026 at 12:22 am

    The problem is the inner table. You didn’t give it a key, which mean that Lua will give it an array index. Namely, 1. Which will overwrite the [1] key you used for "hello??". So you need to give this table value a proper key, or you need to stop using integer keys for the others.

    Or, to put it another way, the following two tables are identical:

    {"first", "second", "third"}
    
    {[3] = "third", [2] = "second", "first"} --Note the lack of a key for "first".
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a problem that was partially solved. To explain it quickly : I
I had to create a work item template.In order to do it quickly.I created
I had a need to do a case insensitive find and found the following
I was wondering if anyone had any luck with the following senario in flex.
I wrote a program to generate large .SQL files for quickly populating very large
In order to find quickly the location of my data, I display a table
Is there a way to quickly collapse all function definitions in the Flash Builder
I would like to quickly send email from the command line. I realize there
Sometimes I need to quickly extract some arbitrary data from XML files to put
I need to quickly (and forcibly) kill off all external sessions connecting to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.