In Scala the dot notation is in much cases optional, like 1 + 2 equals 1.+(2).
But is it also possible, with some magic, to write also things like:
object u {
def meth (s: String) = println(s)
meth "str" // as shortcut for meth("str")
}
Result:
<console>:3: error: ';' expected but string literal found.
But this would be very interesting for creating internal DSLs, if something like this works. Note: In this hypothetical question I’ll don’t want to draw on things like u meth "str".
You can do something similar using string interpolation from Scala 2.10, but I don’t think you should:
It isn’t possible to use expressions like
meth "str"in Scala. You can writeu meth "str","str" meth,meth"str"ormeth ("str"), but notmeth "str".