Default Arguments

You will learn about default arguments in this lesson.

We'll cover the following

This chapter covers two D features that bring flexibility to parameters when calling functions:

  • Default arguments
  • Variadic functions

Default arguments

Function parameters are convenient because of their ability to specify default values for them. This is similar to the default initial values of struct members.

Some parameters of some functions are called mostly by the same values. For example, let’s consider a function that prints the elements of an associative array of type string[string]. Let’s assume that the function takes the separator characters as parameters as well:

Get hands-on with 1000+ tech skills courses.