I found in Scala: can't write setter without getter? that you can't create a setter without getter:
The interpretation of an assignment to a simple variable x = e depends on the definition of x. If x denotes a mutable variable, then the assignment changes the current value of x to be the result of evaluating the expression e. The type of e is expected to conform to the type of x. If x is a parameterless function defined in some template, and the same template contains a setter function x_= as member, then the assignment x = e is interpreted as the invocation x_=(e ) of that setter function. Analogously, an assignment f.x = e to a parameterless function x is interpreted as the invocation f.x_=(e ). An assignment f(args) = e with a function application to the left of the ‘=’ operator is interpreted as f.update(args, e ) , i.e. the invocation of an update function defined by f .
So it is a design decision to not allow setters without getters. But why? Is it just be harder to implement or is it fundamentally impossible to do?
I do have a valid use case for it, using it as a (somewhat complex) setter, where not using this syntactic sugar would break having the same syntax everywhere in the project.