Lua - Multiple Assignments

Published 2014/03/03 by Admin in LUA

You are able to make multiple assignments at the same time.

  • a,b,c,d,e = 1, 2, "three", "four", 5

 

The above assign is equivalent to the code below.

  • a = 1
  • b = 2
  • c = "three"
  • d = "four" 
  • e = 5
This allows for interesting swapping of values.
  • a = 1
    b = 2 
  • a,b = b,a 
  • now a = 2 and b = 1

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

my coding

This is a collection of all the coding gems I have found and would like to share with the world!