This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is lazy initialization.  RSS feed

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is lazy initialization.Kindly explain this with an example.
 
Lalit K Kumar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lazy initialization is postponing the initialization of a variable until it is really needed.
More information at
http://www.cincomsmalltalk.com/CincomSmalltalkWiki
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for example

where a SomeThingOrOther is a SomeThing but not AThing
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ThisThing ThatThing TheOtherThing and AnyOldThing ... starts to sound like Abbot & Costello! Anyhow, good example. This is a valuable trick when creating ItsAlwaysSomeThingIsntIt is very expensive - maybe a call to a remote server somewhere - and you may or may not ever need it. You spend time getting only the data you need, and the client who calls this method never knows about any complexity. All good.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!