Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 465 Bytes

how-to-prepend-an-element-to-array.md

File metadata and controls

25 lines (19 loc) · 465 Bytes

How to prepend an element to array

table.insert(arr, 1, 'val')
  • table.insert - will append given value to the given array
  • arr - array to append value to
  • 'val' - value to append to array
  • , 1 - will insert new value at the beginning (first element) of the array

group: array_add

Example:

arr = {2, 3}
table.insert(arr, 1, 1)
print(table.concat(arr, ', '))
1, 2, 3

link_youtube: https://youtu.be/4SN3NkPB78k