Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you enable a postfix operator in scala?

Tags:

scala

For example, when I try to run:

import scala.concurrent.duration._
Await.result(f, 1 seconds)

I get the error:

postfix operator seconds needs to be enabled

How do I do that?
Why do I need that step when I already included the import?


See also - Other question for a previous scala version with different error message covering a similar case but with an ! operator for working with files, but this does not ask the general quesion of how to disable postfix operators, or answer the question of how to use scala.concurrent.duration.

like image 596
Jethro Avatar asked Oct 14 '25 17:10

Jethro


1 Answers

Some of Scalas modular language features need enabling.
Enabling can just be done by using the appropriate import.
In this case it's:

import scala.language.postfixOps
like image 160
Jethro Avatar answered Oct 17 '25 11:10

Jethro