2

I am new to Scala, and many times i see code like this

implicit val timeout = Timeout(5 seconds)

with Intelij, I could press alt + enter to import Timeout. But can't for 5 seconds. Have to search google to remember the duration._

Thang Hoang
  • 250
  • 5
  • 22
  • Not sure what you mean. You can define templates, such that every new scala file will have the desired import statement. However, I hardly believe you need this in every file? Since it could be anything, you want to import (based on the class name), I guess IntelliJ will have to do some querying.. – rethab Jan 03 '16 at 14:17
  • I copy that code to Intelij, it will show error that unknow Timeout. I move mouse to the line & press `alt + enter`, then I could import `akka.util.Timeout`, but not for `5 seconds`, then I have to google some where to copy `scala.concurrent.duration._`. with Eclipse there is static template definition, that I could add [static import](http://stackoverflow.com/questions/288861/eclipse-optimize-imports-to-include-static-imports) – Thang Hoang Jan 03 '16 at 14:29

1 Answers1

2
implicit val timeout = Timeout(5 seconds) 

is actually means

implicit val timeout = Timeout(duration.DurationInt(5).seconds) 

where "DurationInt" is implicit convertion function.

Unfortunatelly both IDEs are unable to search for implicit conversions to import. So if you want them to add import statemtn automtically try second variant.