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

15
LINES

< > BotCompany Repo | #1011313 - hijackPrint - hijack the print function for a function call, return printed contents; can be nested

JavaX fragment (include)

static S hijackPrint(O r) {
  final new StringBuilder buf;
  O old = interceptPrintInThisThread(new F1<S, Bool>() {
    public Bool get(S s) {
      buf.append(s);
      false;
    }
  });
  try {
    callF(r);
    ret str(buf);
  } finally {
    interceptPrintInThisThread(old);
  }
}

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, xrpafgyirdlv

No comments. add comment

Snippet ID: #1011313
Snippet name: hijackPrint - hijack the print function for a function call, return printed contents; can be nested
Eternal ID of this version: #1011313/6
Text MD5: 801913faa1bfe5c142dbecf144e70ee0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-24 01:22:37
Source code size: 299 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 311 / 333
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1011313 & http://1011313.tinybrain.de