![]() ![]() Exampleįor _, v in pairs(a) do print(v) end Output 10 Now let’s use the generic for loop to print all the elements inside the table that were returned from the table.pack() function. It should be noted that when we pass the values as an argument then an additional field in the table is added which is generally something like this − Īnd then, we can use this n also. In the above example, we passed three numbers to the table.pack() function as an argument and then we are printing the returned value, i.e., which will hold the address of the table that contains the value that we passed as an argument and lastly we are printing the number of elements that are present in the table with the help of the n keyword. The table.pack() function provides a table formed with all the values that are passed to it as an argument, consider the example shown below − The table.pack() function is a variadic function. When we want to return a table as a result from multiple values passed into a function, then we make use of the table.pack() function. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |