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).

1  
// returns IF0 (already evaluated) or null when method not found
2  
3  
// varargs assignment fixer for a single string array argument
4  
static IF0 call_optional(O o, S method, S[] arg) {
5  
  ret call_optional(o, method, new O[] {arg});
6  
}
7  
8  
static IF0 call_optional(O o, S method, O... args) {
9  
  if (!canCallWithVarargs(o, method, args)) null;
10  
  ret if0_const(call(o, method, args));
11  
}

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: 154 / 201
Version history: 2 change(s)
Referenced in: [show references]