The tour isn’t explicit about the line-savings you get via formal properties in Scala classes. Gone are the silly getters and setters.
Instead of writing
setName(String), Scala not only allows you to use
name=, but it will also generate your accessors for you, based on your class constructor definition:
My Thoughts on this Feature
Solid gold money. Why they have yet to add this to Java is beyond me, and this is just extremely helpful. I don’t quite understand why I need
_= instead of just
=, but, whatever. This is a great feature. It’s even more compact than Ruby’s
Last Updated 08/07/2009 at 11:52:26 AM by davecblog comments powered by Disqus
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.