Is there a best practice for one over the other? I\'ve been reading the Scala book by Odersky, et al. and it seems like infix is used for a lot of the Collections
There is a good style guide in official Scala site documentation that describe proper usage infix notation over dot notation.
Suffix Notation:
names.toList
// is the same as
names toList // Unsafe, don't use!
Arity-1:
// right!
names foreach (n => println(n))
names mkString ","
optStr getOrElse ""
// wrong!
javaList add item
Higher-Order Functions:
// wrong!
names.map (_.toUpperCase).filter (_.length > 5)
// right!
names map (_.toUpperCase) filter (_.length > 5)
Symbolic methods/Operators:
// right!
"daniel" + " " + "Spiewak"
// wrong!
"daniel"+" "+"spiewak"