Basics of Programming, Variables, Function — Arguments and Return in Mojo Programming Language: Programming in Mojo — Part IV
Mojo Programming Language combines the usability of Python but with the performance of C, C++ and Rust. Mojo Programming Language has next-generation compiler technologies with features like caching, multithreading and cloud distribution technologies and also, Auto-Tuning and compile-time Metaprogramming features allows to write code for various hardware. Usability & Programmability, best performance, Interoperability and Extensibility are the Advantages of Mojo Programming Language.
Programming in Mojo:
In this Blog, Programming in Mojo is done using Mojo Playground. In Mojo Programming Language functions are defined using def keyword and also using fn keyword. In this Article/Blog, we are going to see function declared using fn keyword only.
Variables:
For type-safety and improved performance, System Programmers wants to declare that a value is immutable. They may want to raise an error if they mistype a variable name in an assignment. To support this, as already discussed in Programming in Mojo — Part III, Mojo Programming Language provides scoped runtime value declarations, var keyword is used to create variable which is mutable (i.e the value of the variable is mutable) and let keyword is used to create variable which is immutable (i.e the value of the variable is immutable).
Function — Arguments and Return:
Type Declaration for variables is not required in the function body, but they are required for arguments and return values for functions declared using fn keyword.
Example:
We had seen about Basics of Programming, Variables, Function — Arguments and Return in Mojo Programming Language. Programming in Mojo and Mojo Programming concepts will be discussed further.
Thankyou for reading this blog on Basics of Programming, Variables, Function — Arguments and Return in Mojo Programming Language: Programming in Mojo — Part IV.
Reference: