Skip to content

Instantly share code, notes, and snippets.

@ademar111190
Last active August 29, 2015 14:17
Show Gist options
  • Save ademar111190/fca309fc9fee1b0800d5 to your computer and use it in GitHub Desktop.
Save ademar111190/fca309fc9fee1b0800d5 to your computer and use it in GitHub Desktop.
One month with Kotlin: lazy example
// Using Lazy on Kotlin
private val foo by Delegates.lazy { Foo(getContext()) }
//------------------------------------------------------------------------------
// Using the nearest from Lazy in Java 7
private Foo mFoo;
public Foo getFoo() {
if (mFoo == null) {
mFoo = new Foo(getContext());
}
return mFoo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment