Skip to Content
Lua Quick Start Guide
book

Lua Quick Start Guide

by Gabor Szauer
July 2018
Beginner
202 pages
5h 42m
English
Packt Publishing
Content preview from Lua Quick Start Guide

Tables are references

The last thing to know about tables before moving on to the next section is that they are stored by reference, not value! This is very important: integers and other primitive types are assigned by value, tables are assigned by reference. What does this mean?

If you assign one variable to another variable by value, each variable has its own copy. This means you can edit both variables independently. Here is an example:

x = 10 -- y assigned 10 by valuey = x -- y assigned the value of x (10) by valuex = 15 -- x assigned 15 by valueprint (x) -- 15print (y) -- 10

When you assigned a variable by reference, however, multiple variables might hold the same reference. If you assign the same reference to multiple variables, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Lua Programming

Beginning Lua Programming

Kurt Jung, Aaron Brown
Vim Masterclass

Vim Masterclass

Jason Cannon

Publisher Resources

ISBN: 9781789343229Supplemental Content