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

20
LINES

< > BotCompany Repo | #1006064 // intSum - add field of list << great wording

JavaX fragment (include)

1  
static int intSum(Collection c, S field) {
2  
  int sum = 0;
3  
  for (O o : unnull(c))
4  
    sum += toInt(getOpt(o, field));
5  
  ret sum;
6  
}
7  
8  
static int intSum(Iterable<Int> l) {
9  
  int sum = 0;
10  
  for (Int i : unnull(l))
11  
    if (i != null) sum += i;
12  
  ret sum;
13  
}
14  
15  
static int intSum(int... l) {
16  
  int sum = 0;
17  
  for (int i : unnull(l))
18  
    sum += i;
19  
  ret sum;
20  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006064
Snippet name: intSum - add field of list << great wording
Eternal ID of this version: #1006064/5
Text MD5: 9a10721757938fbb9bd24061ad121c17
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 08:10:48
Source code size: 369 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 504 / 553
Version history: 4 change(s)
Referenced in: [show references]