Evolution of Programming Paradigms šŸ¤Ÿ

What is Function?

In Simple words, the collection of things we want to do , wrap those statements in function.
As a function it contains set of code statements and should receive some
Inputs (arguments) and return Ā output (some value).

Generally , a function is a ā€œsubprogramā€ , that can be called by code external or internal (Recursion).

Dart is true object oriented so even functions are Ā , functions is an object of Function type. Because they can have properties and methods just like any other objects. What distinguishes them from other objects is that functions can be called.

Function Types in Dart

  1. Normal Function / Named Function
  2. Anonymous Function- function having name like main or print. U can also define a nameless function called Anonymous function, the Anonymous function can assign to variable and variable can be pass to another function as an argument , and variable can be return to the function so function return from the function.

Example:

list.sort((a,b){
			return a - b;		
		});

3. Fat Arrow Function - If Function has only line of code , so u can use Fat Arrow of this.

list.forEach((ele)=>print(ele));

Parameters Types in Dart Function

Note : Either Use Named Parameters or Optional Parameters But not Both.

int add({int x, int y}){
return x + y;
}

// Calling 
add();
add(x:10,y:20)
add(y:10);

Functional Programming Fundamentals Video šŸ‘‡

That's all Folks for this tutorial, will catch you in next one , Happy Coding šŸ˜Ž