Skip to main content
How are we doing? Please help us improve Stack Overflow. Take our short survey

All 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 ...
bobismijnnaam's user avatar
-2 votes
1 answer
334 views

Selenium WebDriver PageFactory Webelement initialization

I have more than 500 web-elements in a webpage. If I use Page Object Model with PageFactory.initElements() in selenium it will initialize all the elements once the object is created. Lets says I am ...
Sathya's user avatar
  • 1
0 votes
1 answer
1k views

Best way to lazy initialize struct members?

I have this struct: pub struct NonSteamGame { app_id:String , app_name:String, start_dir:String, icon:String, shortcut_path:String, launch_options:String, is_hidden:bool, ...
Notbad's user avatar
  • 6,336
5 votes
3 answers
2k views

Flutter: Late Initializing a "widget-dot" Class-level Variable in a Stateful Widget -- What's Going on?

Consider the following class level property inside the state class of a stateful widget: int myInt = widget.int; Android Studio informs that: "The instance member 'widget' can't be accessed in ...
Nerdy Bunz's user avatar
  • 7,556
0 votes
1 answer
410 views

LateInitializationError: Field 'avatar' has not been initialized flutter

Below is how my json looks like { "data": { "id": 2, "email": "[email protected]", "first_name": "Valjakudze", ...
Emmanuel Njorodongo's user avatar
20 votes
1 answer
11k views

What is the equivalent of late | lazy | lateinit in TypeScript?

Dart, Kotlin and Swift have a lazy initialization keyword that lets you avoid the usage of Optional type mainly for maintainability reason. // Using null safety: class Coffee { late String ...
TSR's user avatar
  • 20.9k
3 votes
1 answer
2k views

How can I initialize a companion object property with a value taken from application.properties?

Is it possible to initialize a property of a companion object with some value read from application.properties? I tried // @Value("\${my.property.value}") ...doesn't work val myProp: ...
du-it's user avatar
  • 3,019
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 ...
Gudsaf's user avatar
  • 337
0 votes
2 answers
678 views

Is delayed initialization good or bad? [closed]

I just found a class named HmeRevisionTracker that a colleague created. It merely contains a List<> of simple objects. CSimCharge, one of the most important classes in this project, contains an ...
ROBERT RICHARDSON's user avatar
0 votes
1 answer
702 views

org.hibernate.LazyInitializationException: could not initialize proxy - no Session when trying to initialize

I have an entity that's LAZY fetch called Player. I'm trying to manually have hibernate initialize it but I'm getting that error as if I'm trying to use the Player entity before it's initialized. Here'...
Nelson Matias's user avatar
3 votes
1 answer
580 views

Is eager thread_local initialization possible in C++?

[basic.stc.thread] states that "A variable with thread storage duration shall be initialized before its first odr-use (6.2) and, if constructed, shall be destroyed on thread exit." Does this preclude ...
Jeff's user avatar
  • 3,525
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 ...
Michael Blankenship's user avatar
2 votes
2 answers
610 views

Lazy Initialization sounds and works great. Why not always default to using lazy initialization?

Seems like lazy initialization is great. I understand the concept and have tested on my code and I don't see any lags. Then the question is, why not always use lazy initialization? What's the drawback ...
shle2821's user avatar
  • 1,886
0 votes
1 answer
441 views

Are function scope static or thread_local variables initialized in first entry in C++11?

In C++11 the initialization of function scope static/thread_local variables are guaranteed to be thread safe. Are they also guaranteed to be initialized on function entry?
Siyuan Ren's user avatar
  • 7,844
0 votes
1 answer
865 views

Set lazy var from outside without initializing [closed]

I defined a class using a lazy var definition, where EXIFData is a struct: struct EXIFData { var a : String var b : String } class xxx { ... lazy var exif: EXIFData = { ... ...
Peter Silie's user avatar

15 30 50 per page