Equivalent of Python's Pass in Scala
pass
is a syntactic quirk of Python. There are some cases where the grammar requires you to write a statement, but sometimes you don't want a statement there. That's what pass
is for: it's a statement that does nothing.
Scala never requires you to write a statement, therefore the way to not write a statement is simply to not write a statement.
I think ()
is similar.
scala> def f() = ()
f: ()Unit
scala> f
scala>
As i understand in python pass
is used for not yet implemented cases. If you need such thing in scala then use ???
it's similar to ()
, but is a function returning Nothing (def ??? : Nothing = throw new NotImplementedError
) . Your code will compile, but if you call such a method it will crash with NotImplementedError
def foo: ResultType = ???