inputController::handleFileSelection
is Java syntax, which isn’t supported or needed in Scala because it already had a short syntax for lambdas like this: inputController.handleFileSelection _
or inputController.handleFileSelection(_)
(inputController.handleFileSelection
can also work, depending on the context).
However, in Java you can use lambdas and method references when any SAM (single abstract method) interface is expected, and EventHandler
is just such an interface. In Scala before version 2.11 this isn’t allowed at all, in 2.11 there is experimental support for using lambdas with SAM interfaces, which has to be enabled using -Xexperimental
scalac flag, and starting from 2.12 it is fully supported and doesn’t need to be enabled.