Mukul Latiyan has Published 474 Articles

Concatenation of tables in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 14:05:05

6K+ Views

We can append two tables together in Lua with a trivial function, but it should be noted that no library function exists for the same.There are different approaches to concatenating two tables in Lua. I’ve written two approaches that perform more or less the same when it comes to complexity.The ... Read More

Concatenation of strings in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 14:03:40

2K+ Views

Concatenation of strings is the process in which we combine two or more strings with each other, and in most of the programming languages this can be done by making use of the assignment operator.In Lua, the assignment operator concatenation doesn’t work.ExampleConsider the example shown below − Live Demostr1 = "tutorials" ... Read More

Command Line arguments in Lua

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 14:00:08

4K+ Views

Handling command line arguments in Lua is one of the key features of any programming language. In Lua, the command line arguments are stored in a table named args and we can use the indices to extract any particular command line argument we require.Syntaxlua [options] [script [args]]The options are −-e ... Read More

Code indentation in Lua Programming

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 13:53:46

2K+ Views

Lua codes are not like Python when it comes to indentation. So, most of the code you will write will work even if it falls on another line, and you don’t necessarily need to have the nested code to be intended by a certain tab size.The code indentation in lua ... Read More

Array Size in Lua Programming

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 13:52:36

4K+ Views

It is a general convention that the size of the array is the number of elements that are present inside the array before the nil. In many cases, nil is not allowed in the array, but for some applications, it is not an issue to have nil inside them.If we ... Read More

Alternatives to Lua as an Embedded Language

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 13:50:23

646 Views

An Embedded language is a language that can be used in an application. It is a programming language that adds an ease of performing operations in a specific application.There are many embedded languages that you can use, the most common ones are Lua, LISP, VBA etc.When it comes to choosing ... Read More

__tostring element in Lua Programming

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 13:46:34

2K+ Views

The _tostring element in Lua receives an argument of any type and converts it to a string in a reasonable format.If the metatable of e has a "__tostring" field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result.The __tostring ... Read More

io.popen() function in Lua Programming

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 13:43:35

9K+ Views

Sometimes we want to execute the system's command and then make use of whatever was returned by them, and in order to do that we simply can either make use of the os.execute() function or io.popen() function.The difference between the os.execute() function and the io.popen() function is that the output ... Read More

Install Lua in Linux and implement PHP Lua Extension

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 13:42:01

310 Views

There are cases where we would like to implement PHP Lua extension in PHP.ini so that we can make use of Lua as an embedding language for our PHP code.It can be done with some series of steps that need to be run in a specific manner and the most ... Read More

Inline conditions in Lua (a == b ? “yes” : “no”)

Mukul Latiyan

Mukul Latiyan

Updated on 20-Jul-2021 13:38:25

1K+ Views

You might have noticed ternary operators in different programming languages, but since there’s no ternary operator in Lua, as per the official documentation, we can create one for ourselves with the help of the Lua operators.Let’s first understand what a ternary operator is and why we need one.ExampleConsider the example ... Read More

Advertisements