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

6
LINES

< > BotCompany Repo | #1018064 // shortenToMaxLinesAndChars - actually uses one more line for the ...

JavaX fragment (include)

1  
sS shortenToMaxLinesAndChars(S s, int maxLines, int maxChars) {
2  
  s = shorten(s, maxChars);
3  
  LS lines = lines(s);  
4  
  if (l(lines) <= maxLines) ret s;
5  
  ret lines(takeFirst(maxLines, lines)) + "...";
6  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018064
Snippet name: shortenToMaxLinesAndChars - actually uses one more line for the ...
Eternal ID of this version: #1018064/2
Text MD5: 95d7d85b03f9498c4751dda75578c2aa
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-29 12:30:39
Source code size: 207 bytes / 6 lines
Pitched / IR pitched: No / No
Views / Downloads: 340 / 380
Version history: 1 change(s)
Referenced in: [show references]