Errata

Practical Scala for Java Developers

Errata for Practical Scala for Java Developers

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
17
4:40

In the 17th lesson video, "Default Arguments in Scala", it is stated that you can't specify the value for an argument without specifying the values for all preceding arguments in the method signature. This seems to ignore the fact that Scala allows specifying the argument name for each value in the method call: http://docs.scala-lang.org/tutorials/tour/named-parameters. I have tried it with their example and found it to work:
foo(a = 4, c = 3)

Tom Reedy  Dec 31, 2016 
19
vid 19 6:15

The suggested solution for the exercise is "to have 4 separate overloads of the same function". i get a type mismatch error, when i try this. what am i doing wrong?

def isLeapYear(ld:LocalDate):Boolean = {
val cal = Calendar.getInstance
cal.set(Calendar.YEAR, ld.getYear)
cal.getActualMaximum(Calendar.DAY_OF_YEAR) > 365
}
def isLeapYear(d:UDate):Boolean = {
val ld = d.toInstant.atZone(ZoneId.systemDefault).toLocalDate
isLeapYear(ld)
}
...

ben marengo  Jul 09, 2017