Libraryless. Click here for Pure Java version (10113L/58K).
1 | // We assume all elements of the replacements array are just identifiers |
2 | // (or similarly simple) so there is no tokenization conflict |
3 | // between javaTok and javaTokForStruct |
4 | sS structWithReplacements(O object, S... replacements) {
|
5 | S s = struct(object); |
6 | LS tok = javaTokForStruct(s); |
7 | bool change; |
8 | for (int i = 0; i < l(replacements); i += 2) |
9 | if (jreplace(tok, replacements[i], replacements[i+1])) |
10 | set change; |
11 | ret change ? join(tok) : s; |
12 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1030499 |
| Snippet name: | structWithReplacements |
| Eternal ID of this version: | #1030499/3 |
| Text MD5: | 09c8fd9b51385888d001b2ed6858324d |
| Transpilation MD5: | 6babc8d635e3cad01984398a8b3f9789 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-05-01 17:04:54 |
| Source code size: | 469 bytes / 12 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 412 / 567 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |