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

11
LINES

< > BotCompany Repo | #1031368 // call_optional - wrap result in Optional or null if method not found

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2790L/16K).

// returns IF0 (already evaluated) or null when method not found

// varargs assignment fixer for a single string array argument
static IF0 call_optional(O o, S method, S[] arg) {
  ret call_optional(o, method, new O[] {arg});
}

static IF0 call_optional(O o, S method, O... args) {
  if (!canCallWithVarargs(o, method, args)) null;
  ret if0_const(call(o, method, args));
}

Author comment

Began life as a copy of #1000630

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031368
Snippet name: call_optional - wrap result in Optional or null if method not found
Eternal ID of this version: #1031368/3
Text MD5: c48073e5681cb5b33fafd892f1b59289
Transpilation MD5: b9e1fc36cadc155ecc0f24516f169cc8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-07 10:11:45
Source code size: 384 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 147 / 193
Version history: 2 change(s)
Referenced in: [show references]