Yes, but i wondered is there is a way to create ge...
# announcements
a
Yes, but i wondered is there is a way to create generic function for this instead of adding flags for every place like this
d
Maybe what you want is a lazy property?
Copy code
val x: String by lazy {
    // executed only on first access
    expensiveFunction() 
}
a
No, that's not what i need
d
Then I don't see what you want... 😄
What exactly does the boolean flag not solve?
a
I does not solve the situation when i need 5 separate blocks to run once as i don't want to add 5 flags
d
Lazy solves exactly this problem though...
a
Ok here is the case: I have a code that runs every few ms repeatedly, i need to print some output when the specific not-rare case inside of this code is happened but i need only to print it once, since i don't want to flood log with text