Ok, in the quest to compile a more complete, concise answer (if I've missed anything, or gotten something wrong/inaccurate please comment). Please note this isn't a language spec, so I'm not trying to make it exactly academically correct - just more like a reference card:
Class definitions:
Val or Var can be omitted from class parameters which will make the parameter private.
Adding var or val will cause it to be public (i.e. method accessors and mutators are generated).
{} can be omitted if the class has no body i.e.
class EmptyClass
Class instantiation:
Generic parameters can be omitted if they can be inferred by the compiler. However note, if you're types don't match, than the type parameter is always infered so that it matches. So without specifying the type, you may not get what you expect - i.e. given
class D[T](val x:T, val y:T);
This will give you a type error (Int found, expected String)
var zz = new D[String]("Hi1", 1) // type error
Where as this works fine:
var z = new D("Hi1", 1)
== D{def x: Any; def y: Any}
Because the type parameter T is inferred as the least common supertype of the two - Any.
Function definitions:
= can be dropped if the function returns Unit (nothing)
{} for the function body can be dropped if the function is a single statement, but only if the statement returns a value (you need the = sign)i.e.
def returnAString = "Hi!"
but this doesn't work:
def returnAString "Hi!" // compile error - '=' expected but string literal found."
The return type of the function can be omitted if it can be inferred (a recursive method must have it's return type specified)
() can be dropped if the function doesn't take any arguments i.e.
def endOfString {
return "myDog".substring(2,1)
}
which by convention is reserved for methods which have no side effects - more on that later.
() isn't actually dropped per se when defining a pass by name parementer, but is actually quite symantically different notation i.e.
def myOp(passByNameString: => String)
Says myOp takes a pass by name parameter, which results in a String (i.e. it can be a code block which returns a string) as opposed to function parameters
def myOp(functionParam: () => String)
which says myOp takes a function which has zero parameters and returns a String.
(Mind you, pass by name parameters get compiled into functions, it just makes the syntax nicer.)
() can be dropped in the function parameter definition if the function only takes one argument e.g.:
def myOp2(passByNameString:(Int) => String) { .. } // - you can drop the ()
def myOp2(passByNameString:Int => String) { .. }
But if it takes more than one argument, you must include the ()
def myOp2(passByNameString:(Int, String) => String) { .. }
Statements:
. can be dropped to use Operator Notation, which can only be used for infix operators (operators of methods that take arguments). See Daniel's answer for more information.
. can also be dropped for postfix functions
list tail
() can be dropped for postfix operators
list.tail
() cannot be used with methods defined as:
def aMethod = "hi!" // missing () on method definition
aMethod // works
aMethod() // compile error when calling method
Because this notation is reserved by convention for methods that have no side effects, like List#tail (i.e. the invocation of a function with no side effects means that the function has no observable effect, except for its return value).
() can be dropped for Operator Notation when passing in a single argument
() may be required to use postfix operators which aren't at the end of a statement
() may be required to designate nested statements, ends of anonymous functions or for operators which take more than one parameter
When calling a function which takes a function, you cannot omit the () from the inner function definition e.g.:
def myOp3(paramFunc0:() => String) {
println(paramFunc0)
}
myOp3(() => "myop3") // works
myOp3(=> "myop3") // doesn't work
When calling a function that takes a by-name parameter, you cannot specify the argument as a parameter-less anonymous function. E.g. given:
def myOp2(passByNameString:Int => String) {
println(passByNameString)
}
You must call it as:
myOp("myop3")
or
myOp({
val source = sourceProvider.source
val p = myObject.findNameFromSource(source)
p
})
but not:
myOp(() => "myop3") // does't work
IMO, over use of dropping return types can be harmful for code to be re-used. Just look at Specs for a good example of reduced readability due to lack of explicit information in the code. The number of levels of indirection to actually figure out what the type of a variable is can be nuts. Hopefully better tools can avert this problem and keep our code concise.
[1] http://hestia.typepad.com/flatlander/2009/01/scala-for-c-programmers-part-3-pass-by-name.html