Skip to content

Commit e1bb5dd

Browse files
committed
Optional Positional Parameters
1 parent 18a206c commit e1bb5dd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

15_optional_positional_params.dart

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
// 1. Required Parameters
3+
// 2. Optional Positional Parameters
4+
5+
void main() {
6+
7+
printCities("New York", "New Delhi", "Sydney");
8+
print("");
9+
10+
printCountries("USA"); // You can skip the Optional Positional Parameters
11+
12+
}
13+
14+
// Required Parameters
15+
void printCities(String name1, String name2, String name3) {
16+
17+
print("Name 1 is $name1");
18+
print("Name 2 is $name2");
19+
print("Name 3 is $name3");
20+
}
21+
22+
// Optional Positional Parameters
23+
void printCountries(String name1, [String name2, String name3]) {
24+
25+
print("Name 1 is $name1");
26+
print("Name 2 is $name2");
27+
print("Name 3 is $name3");
28+
}

0 commit comments

Comments
 (0)