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

15
LINES

< > BotCompany Repo | #1035985 // mapCloseables_pcall - map() with safe calling (skip elements when failed) and closing each input item

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

Libraryless. Click here for Pure Java version (9185L/51K).

static <A extends AutoCloseable, B> L<B> mapCloseables_pcall(Iterable<A> l, IF1<A, B> f) {
  L x = emptyList(l);
  if (l != null) for (A o : l) try {
    pcall {
      x.add(f.get(o));
    }
  } finally {
    _close(o);
  }
  ret x;
}

static <A extends AutoCloseable, B> L<B> lambdaMapLike mapCloseables_pcall(IF1<A, B> f, Iterable<A> l) {
  ret mapCloseables_pcall(l, f);
}

Author comment

Began life as a copy of #1010000

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035985
Snippet name: mapCloseables_pcall - map() with safe calling (skip elements when failed) and closing each input item
Eternal ID of this version: #1035985/3
Text MD5: f3255b57d0ab8fe73c38a244a97c433f
Transpilation MD5: 71bb32d5f097afadec118b2223fda0c7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-21 02:40:17
Source code size: 389 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 63 / 91
Version history: 2 change(s)
Referenced in: [show references]