Found 33676 Articles for Programming

Comments in Rust Programming

Mukul Latiyan
Updated on 21-May-2021 12:26:33

866 Views

Comments in Rust are statements that are ignored by both the rust compiler and interpreter. They are mainly used for human understanding of the code.Generally, in programming, we write comments to explain the working of different functions or variables or methods to whosoever is reading our code.Comments enhance the code readability, especially when the identifiers in the code are not named properly.In Rust, there are multiple ways in which we can declare comments. Mainly these are −Single-line commentsMulti-line commentsDoc commentsIn this article, we will explore all the three comments.Single-Line commentSingle line comments in Rust are comments that extend up to ... Read More

Comments in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:25:35

428 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

Cascade notation in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:24:22

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. Live Democlass Sample{    var a;    var b;    void showA(x){       this.a = x;    }    void showB(y){       this.b = y;    }    void printValues(){     ... Read More

Break statement in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:24:46

258 Views

The break statement is used when we want to break or terminate the execution of a loop. Once the break statement is reached the control is transferred from the current loop to whatever is written after the loop.It is mostly used in the conditional statement and also in loops of all types. It is present in almost all popular programming languages.Syntaxbreak;Now let's take a very simple example, where we have a variable named num and we are iterating until num > 5. Suppose we want to exit from the loop when we know that the value inside the num variable has ... Read More

Bitwise operators in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:26:03

4K+ Views

Bitwise operators are operators that are used to perform bit-level operations on operands. For example, consider two variables x and y where the values stored in them are 20 and 5 respectively.The binary representation of both these numbers will look something like this −x = 10100 y = 00101We make use of all the bitwise operators in Dart to perform on the values that are shown in the above table (bit values).In the below table all the bitwise operators that are present in Dart are mentioned.Consider the table as a reference.OperatorMeaningExampleDescription&Binary AND( x & y )Will produce 00100|Binary OR( x | ... Read More

Async and Await in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:27:02

1K+ Views

Async and Await keywords are used to provide a declarative way to define the asynchronous function and use their results.The async keyword is used when we want to declare a function as asynchronous and the await keyword is used only on asynchronous functions.Syntaxvoid main() async { .. }If the function has a declared return type, then update the type of the Future to the return type.Future main() async { .. }And finally, we make use of await keyword when we want to wait for the asynchronous function to finish.await someAsynchronousFunction()ExampleLet's consider an example where we are declaring the main function ... Read More

Assignment operators in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:16:05

2K+ Views

We make use of assignment operators whenever we want to assign values to a variable. There are times when we combine assignment operators with arithmetic operators and logical operators to build a shorthand version of both the assignment and arithmetic (or logical) expression. These shorthand versions are also known as compound statements.In the table below, all the assignment operators that are present in dart are mentioned.Consider the table shown below −OperatorDescriptionExpression=Assignment operatora = b+=Add and assign combineda += b is equivalent to a = a + b-=Subtract and assigna –= b is equivalent to a = a - b*=Multiply and ... Read More

Arithmetic operators in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:18:14

1K+ Views

Arithmetic operators are used to perform different arithmetic operations.These arithmetic operations mainly are −AdditionSubtractionMultiplicationDivisionModulus, etc.Let's consider that we have two int variables named x and y, where x is storing the value 10 and y is storing the value 20.In the below table, you can see all the arithmetic operators, with their symbol, name, what output they yield etc.Consider the table shown below −OperatorNameDescriptionOutput+AdditionAddition of two or more operandsx + y = 30-SubtractionSubtraction of the second operand from the firstx - y = -10*MultiplicationMultiplication of two or more operandsx * y = 200/DivisionReturns quotient after divisionx / y = 0.5%ModulusReturns ... Read More

Anonymous function in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:34:45

894 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 − Live Demovoid main() {    var fruits = ["Apple", ... Read More

Abstract Classes in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:16:33

2K+ Views

Abstract classes in Dart are classes that contain one or more abstract methods.Note: Abstract methods are those methods that don't have any implementation.It should also be noted that a class in Dart can be declared abstract using the "abstract" keyword followed by the class declaration. A class that is declared using the abstract keyword may or may include abstract methods.An abstract class is allowed to have both the abstract methods and concrete methods (methods with implementation). Though, on the contrary, a normal class (non-abstract class) cannot have abstract methods.An abstract class is mainly used to provide a base for subclasses to extend and ... Read More

Advertisements