All Questions
4 questions
2
votes
1
answer
51
views
Scala initialization order object vs. val
In the following program an object is reported as null, even though it is clearly initialized.
class MyClass()
class MyOtherClass(c: MyClass)
object Foo {
val myClass = new MyClass()
object ...
1
vote
1
answer
304
views
Scala proper way to initialize ones changed in runtime fields: placeholder/null, None or zero element?
I got class with fields which value at initialization is unknown. But after, in runtime that values is will gained and setted to fields just ones.
I want to decide what first initialization is best ...
2
votes
3
answers
2k
views
Is it possible to declare a val before assignment/initialization in Scala?
In general, can you declare a val in scala before assigning it a value? If not, why not? An example where this might be useful (in my case at least) is that I want to declare a val which will be ...
3
votes
1
answer
3k
views
Rules of initializing companion object values in Scala
My game has a Sounds object like this:
object Sounds {
SoundFactory.setAssetBasePath("mfx/")
val EXPLOSION_0 = ESound("explosion1.ogg")
val EXPLOSION_1 = ESound("explosion2.ogg")
val ...