Mukul Latiyan

Mukul Latiyan

363 Articles Published

Articles by Mukul Latiyan

Page 18 of 37

__tostring element in Lua Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 3K+ 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 element method is a part of the metatables that Lua library provides us and is used to modify the behaviour of the table that we get as an output.The __tostring element method is used to modify the behavior of the output table.Examplecurrtable = setmetatable({ 10, 20, 30 }, {   ...

Read More

Difference between . and : in Lua programming

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

The .(dot) operator in Lua is used to invoke the method of an object, and it is a widely used operator in Lua.The :(colon) operator in Lua is used when you want to pass an invisible parameter to the method of an object that you are calling.Let’s consider an example where we will have an object in which two functions are present and we will try to access these functions, first by making use of the dot operator and secondly by making use of the colon operator.ExampleConsider the example shown below −returnX = {foo = function(x, y) return x end, ...

Read More

How to Convert Perl Compatible Regular Expressions (PCRE) into Lua

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

A regular expression is a special text string that is used to describe a search pattern.PCRE (Perl Compatible Regular Expressions) is a C library implementing regex. It was written in 1997 when Perl was the de-facto choice for complex text processing tasks. The syntax for patterns used in PCRE closely resembles Perl. If you want to learn about PERL and its use cases, you should visit this link.Now, let's take an example to see how to convert a PCRE into Lua and then print it.ExampleConsider the code shown below −"\002\003\004\005\006\007\008\009\010\011\012\”The above string acts as a PCRE and we will convert ...

Read More

How to create a Sandbox in Lua?

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

In order to create a sandbox and to be able to use it we must first understand what a sandbox is and why we need it. A sandbox is term that is used in different fields of computer science, like in case we are talking about the software testing domain, then a sandbox is a testing environment that isolates untested code changes and outright experimentation from the production environment and if we talk about cybersecurity, then a sandbox is an environment that is an isolated virtual machine in which potentially unsafe software code can execute.Sandboxing is basically all about isolating ...

Read More

Anonymous function in Dart Programming

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

A function without a name is known as an anonymous function. They behave in the exact same manner as a normal named function would. The only difference between the named and an anonymous function is how different they are in syntax.Anonymous functions are used in Dart to form closures. An anonymous function contains a self-contained block of codes, also it can be passed as a parameter to another function as well.Anonymous function Syntax(parameterList){    // inner statement(s) }ExampleNow, let's consider a simple example of an anonymous function.Consider the example shown below −void main() {    var fruits = ["Apple", "Mango", ...

Read More

Cascade notation in Dart Programming

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

Cascade notation is used when we want to operate a sequence of operations on the same object. The cascade notation is denoted by the (..) symbol.It is similar to method chaining that we have in other programming languages and it does save us plenty of steps and need of temporary variable.ExampleConsider the following example for a representation of how the cascade notation works in Dart.class Sample{    var a;    var b;    void showA(x){       this.a = x;    }    void showB(y){       this.b = y;    }    void printValues(){       ...

Read More

Comments in Dart Programming

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

Comments are a set of commands that are ignored by the compiler. They are used in a scenario where you want to attach a note to your code or a section of code so that when you visit it later, you can recall it easily.The comment statements are usually ignored during the execution of the program.There are multiple types of comments in Dart, mainly these are −Single line commentsMulti-line commentsDocumentation commentsWe will explore all the above document types in this article.Single Line commentsSingle line comments make use of // (double forward slash). They extend up to a new line character.Syntax// ...

Read More

const keyword in Dart Programming

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

Dart provides us with two ways in which we can declare variables with fixed values. One of them is by declaring a variable with a const keyword, and the other is by declaring the variable with a final keyword.It should be noted that both of them does provide an assurance that once a value is assigned to the variable with them, it won't change, but indeed they are slightly different from one another.constA variable that is declared using the const keyword cannot be assigned any other value. Also, the variable is known as a compile-time constant, which in turn means that ...

Read More

Constructors in Dart Programming

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

Constructors are methods that are used to initialize an object when it gets created. Constructors are mainly used to set the initial values for instance variables. The name of the constructor is the same as the name of the class.Constructors are similar to instance methods but they do not have a return type.All classes in Dart have their own default constructor, if you don't create any constructor for a class, the compiler will implicitly create a default constructor for every class by assigning the default values to the member variables.We can create a constructor in Dart something like this −class ...

Read More

final keyword in Dart Programming

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

The final keyword in Dart is used to create constants or objects that are immutable in nature. The only difference between the final and const keyword is that final is a runtime-constant, which in turn means that its value can be assigned at runtime instead of the compile-time that we had for the const keyword.ExampleConsider the example shown below −void main(){    final int xy = 10;    print(xy); }Output10In the above example, we declared an int variable with a final keyword, which means that the value once assigned to it won't change.ExampleConsider the example shown below −void main(){    final ...

Read More
Showing 171–180 of 363 articles
« Prev 1 16 17 18 19 20 37 Next »
Advertisements