Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1009701 // persistentObject

JavaX fragment (include)

static <A> A persistentObject(S name, Class<? extends A> makeDefaultObject) {
  ret persistentObject(name, (O) makeDefaultObject);
}

// makeDefaultObject: (func -> A) or Class
static <A> A persistentObject(S name, O makeDefaultObject) {
  IVar<A> var = persistentVar(name);
  if (!var.has()) var.set((A)
    (makeDefaultObject instanceof Class ? nu((Class) makeDefaultObject) : callF(makeDefaultObject)));
  ret var!;
}

Author comment

Began life as a copy of #1009539

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009701
Snippet name: persistentObject
Eternal ID of this version: #1009701/5
Text MD5: 9da8e43f0b7d14f290459e72589ceb13
Author: stefan
Category: javax / lists
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-14 17:26:21
Source code size: 430 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 594 / 560
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1009875 - persistentObjectFromProgram - load object stored with persistentObject() by another program