Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following are all valid calls to the above method:

  • sum()  --> returns zero.
  • sum(42)  --> returns 0+42 = 42.
  • sum(10, 20)  --> returns 0+10+20 = 30.
  • sum(100, 1000, 10000)  --> returns 11100 etc

Vararg input parameters are very useful when you might want to call a method, such as the accept method of a host (and hence a case on the visitor), with varying numbers of input parameters, or perhaps, none at all.

...