At just after 2:40 in ShadowofCatron\'s Scala Tutorial 3 video, it\'s pointed out that the parentheses following the name of a thunk are optional. \"B
In your example
def f(): Int = { counter = counter + 1; counter }
is defining a method, not a function. AFAIK methods are promoted to functions automatically in Scala depending on context. To define a function you can write
val f = () => { counter = counter + 1; counter }
and I think you will get what you want.