O'Reilly logo
  • Emran Talukder thinks this is interesting:

val newId: Int = taskList.last.id + 1

From

Cover of Mastering Play Framework for Scala

Note

taskList is empty. therefore there is no taskList.last. you should either add a initial element or val newId = if(todoList.nonEmpty) todoList.last.id + 1 else 0