Core concept

val x = 42         // Int inferred
val s = "hello"   // String
def sq(n: Int) = n * n  // return Int
Advertisement

How it works

Over-inference hurts readability. Always type public API methods.

Advertisement

Trade-offs + gotchas

Local vars + private helpers benefit. Public methods explicit.