-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path#18-Positional_Parameter.dart
More file actions
43 lines (32 loc) · 1.06 KB
/
#18-Positional_Parameter.dart
File metadata and controls
43 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
void main(){
//Optional Positional Parameters in Dart .
//required parameter , you must have to give the parametere to the function like this -->
//else You wil get an Error.
myCountry("India", "Austrilia", "America");
print("");
//Optional Positional Parameter-->
myState("West Bengal");
//if you miss the two parameter you will not get any error beacuse we make 2 parameter optional.
//you will get the value of null in the empty parameter.
}
/*There are two types of parameter in Dart.
1.Reqiured paramerter
2.Optional Paramerter
optional parameter has three types.
1.positional
2.Named
3.default
*/
//Required Parameter in a function-->
void myCountry(var c1,var c2,var c3){
print("First country is $c1");
print("Second country is $c2");
print("Third country is $c3");
}
//Optional positional Parameter -->
void myState(var c1,[var c2,var c3]){
print("First country is $c1");
print("Second country is $c2");
print("Third country is $c3");
}
//we have to use square brackets to make it optional Parametere .