Jump to content

How to loop more table datas under each other?


Turbesz

Recommended Posts

  • Moderators
2 hours ago, Turbesz said:

How can i do it this with loops?

You can combine the tables first with for example this method table.merge. (make sure to copy the code)

And then loop through them.

 

Keep in mind that the table.merge method is mutating the first table. (mutating = changing the content of the table, instead of returning a new one)

table1 = {1,2,3}
table2 = {4,5,6}

----

local newTable = {}

table.merge(newTable, table1, table2)
-- or with table names
table.merge(newTable, {"table1"}, table1, {"table2"}, table2)

 

 

  • Thanks 1
Link to comment
18 hours ago, IIYAMA said:

You can combine the tables first with for example this method table.merge. (make sure to copy the code)

And then loop through them.

 

Keep in mind that the table.merge method is mutating the first table. (mutating = changing the content of the table, instead of returning a new one)


table1 = {1,2,3}
table2 = {4,5,6}

----

local newTable = {}

table.merge(newTable, table1, table2)
-- or with table names
table.merge(newTable, {"table1"}, table1, {"table2"}, table2)

 

 

Thank you, that's exactly what I want!

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...