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

9
LINES

< > BotCompany Repo | #1024020 // switchIfLongerInField

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

Libraryless. Click here for Pure Java version (1619L/11K).

1  
static <A> A mapMethodLike switchIfLongerInField(S field, A newOne, A oldOne) {
2  
  ret switchIfLongerInField(field, newOne, oldOne, null);
3  
}
4  
5  
static <A> A mapMethodLike switchIfLongerInField(S field, A newOne, A oldOne, Runnable onSwitch) {
6  
  ret oldOne == null ? with(onSwitch, newOne)
7  
    : newOne == null ? oldOne
8  
    : cmp(l(getOpt(newOne, field)), l(getOpt(oldOne, field))) > 0 ? with(onSwitch, newOne) : oldOne;
9  
}

Author comment

Began life as a copy of #1024019

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024020
Snippet name: switchIfLongerInField
Eternal ID of this version: #1024020/3
Text MD5: ae09177bdf6be81f6f498f4938493278
Transpilation MD5: 1d9c44c61f5c15ac34b04ad20e024963
Author: stefan
Category: javax / optimization
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-16 00:48:43
Source code size: 426 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 298 / 398
Version history: 2 change(s)
Referenced in: [show references]