O'Reilly logo

Mastering the Nmap Scripting Engine by Paulino Calderón Pale

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Common data structures

In Lua, you will use the table data type to implement all your data structures. This data type has great features such as the ability to store functions and be dynamically allocated, among many others. Hopefully, after reviewing some common data structures, you will find yourself loving their flexibility.

Tables

Tables are very convenient and allow us to implement data structures such as dictionaries, sets, lists, and arrays very efficiently. A table can be initialized empty or with some values:

T1={} --empty table
T2={"a","b","c"}

Integer indexes or hash keys can be used to assign or dereference the values in a table. One important thing to keep in mind is that we can have both types in the same table:

t={} t[1] = "hey " t["nmap"] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required