Mukul Latiyan

Mukul Latiyan

363 Articles Published

Articles by Mukul Latiyan

Page 20 of 37

Read and Write Input in Dart Programming

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

Dart provides us with a standard library named 'io' which contains different classes and in turn, these classes contains different methods that we can use to read or write input from the terminal.We import the library in our program by making use of the import command.ExampleConsider the example shown below −Import 'dart:io';Writing something to the terminalWe can write something to the terminal by making use of the standard out class (stdout) that is available to us in the 'dart:io' library.ExampleConsider the example shown below −import 'dart:io'; void main(List arguments) {    stdout.write('What is your name?\r'); }OutputWhat is your name?Note − ...

Read More

Return statement in Dart Programming

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

There are certain cases where we want to return a value from a given function so that we can use it later. These return values make use of a return keyword which in turn allows a function to return values.It should be noted that the return statement is optional, if not specified the function returns null.Also, only one return statement is allowed in a function.Syntaxreturn ;Syntax of a Dart function with a return value −returnType funcName(){    // statement(s)    return value; }In the above syntax, the funcName is replaced with the name of our function. The returnType represents the type of data/expression ...

Read More

String Interpolation in Dart Programming

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

There are times when we want to make use of variables inside the statement that is made up of string values.We know that we can add two strings together in Dart with the help of the + symbol operator. But to make use of a variable in between the strings that we are concatenating, we need to add one more + symbol and then type the name of the variable, which works okay when it comes to small statements.ExampleConsider the example shown below −void main(){    String name = "Tutorials";    var collegeName = "DTU";    print("Name is " + ...

Read More

Super constructor in Dart Programming

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

The subclass can inherit the superclass methods and variables, but it cannot inherit the superclass constructor. The superclass constructor can only be invoked with the use of the super() constructor.The super() constructor allows a subclass constructor to explicitly call the no arguments and parametrized constructor of superclass.SyntaxSubclassconstructor():super(){ }Though, it is not even necessary to use the super() keyword as the compiler automatically or implicitly does the same for us.When an object of a new class is created by making use of the new keyword, it invokes the subclass constructor which implicitly invokes the parent class's default constructor.Let's make use of an example where ...

Read More

Super keyword in Dart Programming

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

Super keyword in dart is used to refer to the parent's class object's methods or variables. In simple terms, it is used to refer to the superclass properties and methods.The most important use of the super keyword is to remove the ambiguity between superclass and subclass that have methods and variables with the same name.The super keyword is able to invoke the parent's objects method and fields, as when we create an instance of the subclass in Dart, an instance of the parent class is also created implicitly.Syntaxsuper.varName or super.methodNameAs we can access both the variables and methods of the parent's ...

Read More

Ternary Operator in Dart Programming

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

The ternary operator is a shorthand version of an if-else condition. There are two types of ternary operator syntax in Dart, one with a null safety check and the other is the same old one we encounter normally.Syntax 1condition ? expressionOne : expressionTwo;The above syntax implies that if a certain condition evaluates to true then we evaluate the expressionOne first and then the expressionTwo.ExampleLet's explore a Dart example where we make use of the above syntax of the ternary operator.Consider the example shown below −void main(){    var ans = 10;    ans == 10 ? print("Answer is 10") : ...

Read More

This keyword in Dart Programming

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

This keyword in dart is used to remove the ambiguity that can be caused if the class attributes and the parameters have the same name. This keyword basically represents an implicit object pointing to the current class object.We usually prefix the class attribute with this keyword whenever we want to remove the ambiguity between the class attributes and the parameters.ExampleLet's take two examples of the case where the name of the class attribute and the parameters are the same.Consider the example shown below −void main() {    Employee emp = new Employee('001');    emp.empCode = '111'; } class Employee ...

Read More

Casting in Rust Programming

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

Casting or explicit conversion is only allowed in Rust, there’s no implicit conversion that the compiler of Rust does for us. It is known that, in many cases, implicit conversion can lead to data losses, which is not a good thing.Rules for converting between different types is pretty similar to C. In Rust though, we make use of as keyword when we want to convert from one type to another.Example:Consider the following example:// Suppress all warnings from casts which overflow. #![allow(overflowing_literals)] fn main() {    let decimal = 65.43_f32;    // Error! No implicit conversion    // let ...

Read More

From and Into Traits In Rust Programming

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

From and Into are two traits that Rust provides us. They are internally linked.From TraitWe make use of From trait when we want to define a trait to how to create itself from any other type. It provides a very simple mechanism with which we can convert between several types.For example, we can easily convert str into a String.ExampleConsider the example shown below:fn main() {    let my_str = "hello";    let my_string = String::from(my_str);    println!("{}", my_string); }OutputhelloWe can even convert our own types.ExampleConsider the example shown below:use std::convert::From; #[derive(Debug)] struct Num {    value: i64, } impl From ...

Read More

HashMap in Rust Programming

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

HashMap is an important data structure, as it allows us to store data in key-value pairs. In Rust, HashMap stores values by key.HashMap keys can be Boolean, Integer, strings or any other data type that implements the Eq and Hash traits.HashMaps can grow in size, and when the space becomes too excessive, they can also shrink themselves.We can create a HashMap in multiple ways, we can use either HashMap::with_capacity(uint) or HashMap::new().Following are the methods that HashMaps support:insert()get()remove()iter()ExampleLet’s see an example where we build a HashMap and use all these operations stated above.Consider the example shown below.use std::collections::HashMap; fn call(number: ...

Read More
Showing 191–200 of 363 articles
« Prev 1 18 19 20 21 22 37 Next »
Advertisements