Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a raywenderlich.com Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Understand Named Parameters

This video was last updated on Jun 21 2022

Named parameters make your function easier to use and easier to read. Learn how to define named parameters to make your code self documenting.

Contributors

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

So far in defining functions, you will have noticed that often times, it’s difficult to determine the meaning of the value being passed into it.

bool isWithinTolerance(int value, [int min = 0, int max = 10]) {
  return min <= value && value <= max;
}
bool isWithinTolerance(int value, {int min = 0, int max = 10}) {
  return min <= value && value <= max;
}
print(isWithinTolerance(9, min: 7, max: 11));
print(isWithinTolerance(9, max: 11));
print(isWithinTolerance(9, max: 11, min: 5));
print(isWithinTolerance(9));
bool isWithinTolerance({ int value, int min = 0, int max = 10})
bool isWithinTolerance({ required int value, int min = 0, int max = 10})
print(isWithinTolerance(value: 9, max: 11, min: 5));

Reviews

Comments