Mukul Latiyan

Mukul Latiyan

363 Articles Published

Articles by Mukul Latiyan

Page 7 of 37

Why does Lua have no "continue" statement?

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 5K+ Views

There’s no continue statement in Lua, and it’s not because the developers of the Lua programming language felt that it is of no use, in fact, in the official documentation they mentioned “continue was only one of a number of possible new control flow mechanisms”. This clearly shows that the developers of the Lua programming language aren’t a huge fan of the “continue” statement.If we need to break it down the fact that why Lua developers doesn’t wanted a “continue” statement, then it comes down to two possible answers, these are −They think that the “continue” statement is just another ...

Read More

Lexical Conventions in Lua Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 485 Views

In this article, we will learn how to declare and write different lexical conventions in Lua programming.In Lua, we call NAMES as IDENTIFIERS and they can be any string of letters, digits, and underscored, and they should not begin with a digit.Let’s consider an example of different Identifiers in Lua and see which ones are valid and which aren’t.ExampleConsider the example shown below −i = 10 print(i) j1 = 11 print(j1) _ij = 99 print(_ij) aVeryLongName = "Tutorials point" print(aVeryLongName)In the above example, all the variables (Identifiers) are valid, as they either start with letters, digits, or ...

Read More

math.ceil() function in Lua programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 7K+ Views

There are several occurrences when we want to get the ceil value of an integer to round it off and then use that value later on.The Ceiling value of a number is the value that is rounded to the closest integer greater than or equal to that integer.Lua provides us with a math.ceil() function that we can use to find the ceil value of a number.ExampleLet’s consider a simple example where we will make use of the math.ceil() function in Lua −a = math.ceil(3.3) b = math.ceil(7.1) print(a) print(b)Output4 8ExampleIt should be noted that if we try to find ceil ...

Read More

math.max() function in Lua programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 10K+ Views

There are several occurrences when we want to get the max value from a given series of numbers and then use that value later on.The Maximum value from the series of different numbers is the value that is the maximum of all the numbers that are present in that series.Lua provides us with a math.max() function that we can use to find the max value out of different numbers that we pass to it as arguments.ExampleLet’s consider a simple example where we will make use of the math.max() function in Lua −a = 10 b = 11 c = 12 ...

Read More

math.min() function in Lua

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 8K+ Views

There are several occurrences when we want to get the min value from a given series of numbers and then use that value later on.The Minimum value from the series of different numbers is the value that is the minimum of all the numbers that are present in that series.Lua provides us with a math.min() function that we can use to find the min value out of different numbers that we pass to it as an argument.ExampleLet’s consider a simple example where we will make use of the math.min() function in Lua −a = 10 b = 11 c = ...

Read More

math.modf() function in Lua programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 3K+ Views

There are several occurrences when we want to get the integer value of a number and also the fractional value that the number has if any, so that we can use either or both of these values.Lua provides us with a math.modf() function that we can use to find the integer value along with the fractional value if the number has any.Syntaxmath.modf(number)The math.modf() function returns two values when we call the function, the first value is the integer value of the number and the second returned value is the fractional value of the number if it has any.ExampleLet’s consider a ...

Read More

select() function in Lua programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 13K+ Views

The select function in Lua is used to return the number of arguments that are passed into it as an argument. It can be used in two forms, the first one includes passing an index and then it will return the numbers that are passed after that number into the function as an argument in a list format, the other pattern is if we pass the length operator as a first argument, in that case it simply returns a count of the multiple arguments that are provided.ExampleLet’s explore both the cases in the examples shown below.Case 1print(select(1, "a", "b", "c")) ...

Read More

Semicolon Conventions in Lua Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 804 Views

There are very few sections we will explore the possibility of making use of a semicolon in Lua. Majority of the code doesn’t require it, while there are some cases where we might need them.ExampleLet’s consider a case where the use of semicolon seems necessary. Consider the example shown below −local a, b=10, 20 print(a+b)The above statement in Lua is perfectly valid and it works like a charm.Output30ExampleWhat if we change the code above and put it in the same line? Would it still be a valid Lua code? Let’s try it out. Consider the code shown below −local a, ...

Read More

string.byte() function in Lua programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 12K+ Views

The string.byte() function is one of the most widely used Lua string library functions that takes a character or a string as an argument and then converts that character into its internal numeric representations.The character to internal numeric representations can be easily interpreted from the ASCII table.Syntaxstring.byte(ch) or string.byte(ch, idx)In the above representation of the string.byte() function, the ch identifier represents the character that we want to convert into a decimal value. Also, the idx identifier represents a character at that index of the string passed as an argument.Let’s consider a few examples where we will make use of the ...

Read More

string.char() function in Lua programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 7K+ Views

There are so many scenarios where you might want to convert a decimal value into a character representation. The character representation of a decimal or integer value is nothing but the character value, which one can interpret using the ASCII table.In Lua, to convert a decimal value to its internal character value we make use of the string.char() function.Syntaxstring.char(I)In the above syntax, the identifier I represents the decimal value which we want to convert into a character.ExampleLet’s consider a very simple example, where you are given different decimal values, and you want to convert them to a character value.Consider the ...

Read More
Showing 61–70 of 363 articles
« Prev 1 5 6 7 8 9 37 Next »
Advertisements