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

10
LINES

< > BotCompany Repo | #1015295 // smartLastIndexOf - returns l(s) if not found

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

Transpiled version (2580L) is out of date.

1  
static int smartLastIndexOf(S s, char c) {
2  
  if (s == null) ret 0;
3  
  int i = s.lastIndexOf(c);
4  
  ret i >= 0 ? i : l(s);
5  
}
6  
7  
static <A> int smartLastIndexOf(L<A> l, A sub) {
8  
  int i = lastIndexOf(l, sub);
9  
  ret i < 0 ? l(l) : i;
10  
}

Author comment

Began life as a copy of #1002497

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, ofpaelxlmzfo, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1015295
Snippet name: smartLastIndexOf - returns l(s) if not found
Eternal ID of this version: #1015295/5
Text MD5: b7dddfcd91c4681ce61d88b6d4b3461f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-10-31 12:33:04
Source code size: 237 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 339 / 818
Version history: 4 change(s)
Referenced in: [show references]