Core_Dumped
Core_Dumped

Reputation: 4699

Different arguments in Seq() in Scala

In the code I am going through, a sequence having LocalDate type variables as elements has been passed to a function which in turn is been interpreted in the following way:

Seq(acquisitionDate: LocalDate, head: LocalDate, tail @ _*)

As far as I can understand, acquisitionDate is the last element, head is the first element and tail is all the elements in between.. Am I right?

Upvotes: 0

Views: 73

Answers (1)

om-nom-nom
om-nom-nom

Reputation: 62835

Depending on the context it might be a pattern matching, which affect what is going on there (in a minor way, of course). acquisitionDate is the first argument, head is the second, tail is the rest (it will be expanded by the compiler into third, fourth and so on arguments). In addition there is type ascription, which may upcast variable to some specific type, but usually serves as a documentation. Without type ascription it might look like:

Seq(acquisitionDate, head, tail @ _*)

Upvotes: 1

Related Questions