I'm reading the source of a project, and found such code there:
private var _responded: Boolean = _
{
_responded = false
}
I don't understand why he wrote it like this, isn't it the same as:
private var _responded = false
What's the difference between them?
I'm the author of that code.
Writing like this:
private var _responded = false
causes this warning on compilation (with older versions of Scala, seems no problem with Scala 2.9):
the initialization is no longer be executed before the superclass is called
You can google about that warning to find more information.
I'm going to hazard a guess here, but that looks a lot like the code produced by intellij's automatic Java to Scala conversion.
This converter tries to maintain the semantics of the original Java as closely as possible, and so tends to produce very non-idiomatic code, as well as lots of nested scopes and mutable variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With