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

16
LINES

< > BotCompany Repo | #1032716 // HostAndPort

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

Libraryless. Click here for Pure Java version (3935L/23K).

1  
srecord HostAndPort(S host, int port) {
2  
  *(S s) {
3  
    int i = indexOf(s, ':');
4  
    if (i < 0)
5  
      host = s;
6  
    else {
7  
      host = takeFirst(i, s);
8  
      port = parseInt(dropFirst(i+1, s));
9  
    }
10  
  }
11  
  
12  
  toString {
13  
    //ret host + (port == 0 ? "" : ":" + port);
14  
    ret host + ":" + port;
15  
  }
16  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032716
Snippet name: HostAndPort
Eternal ID of this version: #1032716/7
Text MD5: 0c9e3bf32fbb1cc2d54851ab48bc26fe
Transpilation MD5: b1947adb2cb98d4c94add74ecec03682
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-03 19:17:59
Source code size: 315 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 111 / 219
Version history: 6 change(s)
Referenced in: [show references]