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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:29:52+00:00 2026-05-26T21:29:52+00:00

I am starting to learn Lua from Programming in Lua (2nd edition) I didn’t

  • 0

I am starting to learn Lua from Programming in Lua (2nd edition)
I didn’t understand the following in the book. Its very vaguely explained.

a.) w={x=0,y=0,label="console"}

b.) x={math.sin(0),math.sin(1),math.sin(2)}

c.) w[1]="another field"

d.) x.f=w

e.) print (w["x"])

f.) print (w[1])

g.) print x.f[1]

When I do print(w[1]) after a.), why doesn’t it print x=0

What does c.) do?

What is the difference between e.) and print (w.x)?

What is the role of b.) and g.)?

  • 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-26T21:29:52+00:00Added an answer on May 26, 2026 at 9:29 pm

    You have to realize that this:

    t = {3, 4, "eggplant"}
    

    is the same as this:

    t = {}
    t[1] = 3
    t[2] = 4
    t[3] = "eggplant"
    

    And that this:

    t = {x = 0, y = 2}
    

    is the same as this:

    t = {}
    t["x"] = 0
    t["y"] = 2
    

    Or this:

    t = {}
    t.x = 0
    t.y = 2
    

    In Lua, tables are not just lists, they are associative arrays.

    When you print w[1], then what really matters is line c.) In fact, w[1] is not defined at all until line c.).

    There is no difference between e.) and print (w.x).

    b.) creates a new table named x which is separate from w.

    d.) places a reference to w inside of x. (NOTE: It does not actually make a copy of w, just a reference. If you’ve ever worked with pointers, it’s similar.)

    g.) Can be broken up in two parts. First we get x.f which is just another way to refer to w because of line d.). Then we look up the first element of that table, which is "another field" because of line c.)

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

Sidebar

Related Questions

I am starting to learn Lua from Programming in Lua (2nd edition) I didn't
I am starting to learn the Clojure programming language. Are there any recommendations for
im just starting to learn flex and im trying to understand how Flex does
I'm starting to learn Excel Programming and have been doing the development in Excel
I am starting to learn MVC(3) following a tutorial. I am a developer so
Im starting to learn android programming and i was wondering where i could find
I am starting to learn Silverlight game programming, and was wondering if anyone knows
I am starting to learn Qt4 and Python, following along some tutorial i found
I am just starting to learn jQuery, and want to load content from a
I'm starting to learn and practice some CoreData, with no programming experience. After searching

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.