I am new to java, coming from a ruby ββworld. One thing I love about ruby ββis a very concise syntax like || =.
I understand, of course, that the compiled language is different, but I wonder if Java has something like that.
In particular, what I do all the time in ruby ββis something like:
someVar ||= SomeClass.new
I think this is incredibly eloquent, but powerful, but so far the only way I can think of to achieve the same is a lot:
if(someVar == null){ someVar = new SomeClass() }
Just trying to improve my Java-fu and syntax is, of course, one of the areas in which I'm not a professional.
source share