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 6078943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:53:26+00:00 2026-05-23T10:53:26+00:00

In Lua, assigning a table with a specified key might go like this: a

  • 0

In Lua, assigning a table with a specified key might go like this:

a = { x = 4 }

…or perhaps like…

a = { ['x'] = 4 }

Easy enough. However, if I introduce periods into the key (as in a domain name) nothing seems to work. All of the following fail:

a = { "a.b.c" = 4 }
a = { a.b.c = 4 }
a = { ['a.b.c'] = 4 }
a = { ["a.b.c"] = 4 }
a = { [a.b.c] = 4 }

All of these return the same error:

$ ./script.lua
/usr/bin/lua: ./script.lua:49: `}' expected near `='

What am I missing here? Several of the examples seem quite straight-forward and should work (while others have apparent problems).

  • 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-23T10:53:27+00:00Added an answer on May 23, 2026 at 10:53 am

    In lua table element may be either a Name or an Expression. Citing language reference, “Names (also called identifiers) in Lua can be any string of letters, digits, and underscores, not beginning with a digit.”, and everything else is interpreted as an identifier in this context. Therefore, a.b.c as a table index is treated as expression, which is evaluated to get the actual table index. This would work, but would be useless:

    a = { b = { c = 1 } }
    x = {}
    x['a.b.c'] = 7
    
    print(x['a.b.c'])
    

    Also note, that foo.a.b.c is equal to foo['a']['b']['c'] and not to foo['a.b.c'].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In lua, it's legal to do this : table={} bar if(table[key]==nil) then foo However,
If I have some lua code like this: doSomething(function() print(Hello!) end) How can I
Does Lua support something like C's __LINE__ macro, which returns the number of the
Puzzled by the Lua 5.0 documentation references to things like _LOADED , LUA_PATH ,
In Lua, you can create a table whose keys are themselves tables: t =
I have a lua table that I use as a hashmap, ie with string
In Lua, you can create a table the following way : local t =
In Lua the the __index metamethod can be either a function or a table
I'm integrating Lua into my project at the moment, and I'm facing a small
I'm new to Lua so please bear with this simple question :) I'm simply

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.