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

static <A> A mapMethodLike switchIfLongerInField(S field, A newOne, A oldOne) {
  ret switchIfLongerInField(field, newOne, oldOne, null);
}

static <A> A mapMethodLike switchIfLongerInField(S field, A newOne, A oldOne, Runnable onSwitch) {
  ret oldOne == null ? with(onSwitch, newOne)
    : newOne == null ? oldOne
    : cmp(l(getOpt(newOne, field)), l(getOpt(oldOne, field))) > 0 ? with(onSwitch, newOne) : oldOne;
}

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: 299 / 399
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)