New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maybe a good solution for using postfixOps #9870
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9870?orig=1 |
@soc said: proposals for language changes should first be discussed on the scala-debate/scala-internals mailing list. Thanks! (My personal opinion is that this hasn't a chance of being accepted as it would add an additional way of doing the same thing. The idea of postfix ops was that one could leave out the dot ... now the proposal is to reintroduce it with two dots instead? How would that retain the original benefit (of "one less dot to write")? How would 2 dots after a method be better than the existing way of adding one dot in front of the method?) |
Franklin Zhang (chigou79) said (edited on Jul 26, 2016 12:55:17 PM UTC): import scala.collection.JavaConverters._ def xxx = someJavaStream collect Collectors.toList() asScala and then, use it as a scala collection, but i can't continue directly because the method asScala can't be used as an infix operator, I should change it to: def xxx = (someJavaStream collect Collectors.toList() asScala) map ...... this happened just because the method with zero args isn't able to be regarded as an operator, though i acknowledge using too much operators is not a good habit. |
@dwijnand said: Please open a topic about this on one of the mailing lists and link it here, because I would also like to be able to do this - but then I'm demonstrable in the infix-notation camp already. Here's an example, present in sbt, of a workaround for essentially this issue - to allow for one to continue to use infix notation: https://github.com/sbt/sbt/blob/v0.13.12/ivy/src/main/scala/sbt/ModuleID.scala#L32-L34 |
Franklin Zhang (chigou79) said: And sorry again to @simon Ochsenreither for giving you a dozen of mails because of my frequently editing my comment. I haven't used JIRA before. This must have bothered you. |
I have an idea about using an method without parameter as an operator. Maybe we can introduce a symbol like .. or a new identifier to show that the method before it need no parameter.
import scala.language.xxx
"Hello" toList .. foreach println
or
import xxx.??
"Hello" toList ?? foreach println
I think this is elegant, isn't it?
The text was updated successfully, but these errors were encountered: