Skip to content

Commit

Permalink
Optional Default Parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
smartherd committed Jun 27, 2018
1 parent 5a25868 commit f069a93
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions 17_default_parameters.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

// Optional Default Parameters

void main() {

findVolume(10); // Default value comes into action
print("");

findVolume(10, breadth: 5, height: 30); // Overrides the old value with new one
print("");

findVolume(10, height: 30, breadth: 5); // Making use of Named Parameters with Default values
}


int findVolume(int length, {int breadth = 2, int height = 20}) {

print("Lenght is $length");
print("Breadth is $breadth");
print("Height is $height");

print("Volume is ${length * breadth * height}");
}

0 comments on commit f069a93

Please sign in to comment.