Using infix notation is exactly that - notation. There is no effect on code etc.
I also personally tend to favour the more verbose dot notation (perhaps due to
java background ). More readable IMO with the exception of DSLs where it can be
quite nice.
FWIW Spark prefers dot notation for readability and also it is more familiar
for people coming from a Java background and I believe this approach is a must
for mixed Scala/Java projects.
One style issue I see is map with case doesn't need parentheses, ie you can do:
val columnIDs = interactions.map { case (_, columnID) => columnID
}.distinct().collect()
Which is more readable too in my view :)
—
Sent from Mailbox
On Thu, Jun 19, 2014 at 7:12 PM, Sean Owen <[email protected]> wrote:
> For what it's worth: I really prefer the dot notation myself. Yeah
> it's more Java-like and I think that's a good thing for clarity.
> The style guide seems to in general discourage infix except for
> symbolic operators, and also a special case of higher-order functions.
> But the example they give seems to turn on an ambiguity introduced by
> spaces, and nothing to do with infix. I'm confused. But I like dots.
> http://docs.scala-lang.org/style/method-invocation.html
> I don't know of any reason using dots would create a weird or subtle effect.
> On Thu, Jun 19, 2014 at 6:03 PM, Pat Ferrel <[email protected]> wrote:
>> I noticed that some of the Scala code is like this:
>>
>> val columnIDs = interactions.map({ case (_, columnID) =>
>> columnID}).distinct().collect()
>>
>> but as I read the Scala style guide it should use infix notation like this
>>
>> val columnIDs = interactions map ({ case (_, columnID) => columnID})
>> distinct() collect()
>>
>> It seems that the former style, familiar in Java, may have side effects in
>> Scala, but perhaps I’m missing some Scala subtlety? I appears that both work
>> correctly in some tests I did.
>> http://docs.scala-lang.org/style/method-invocation.html#higherorder_functions
>>
>> Before changing all my code am I reading this correctly?
>>
>>
>>