Difference between revisions of "delimiter-prefixed string"
Jump to navigation
Jump to search
(revision to match new title) |
|||
(One intermediate revision by the same user not shown) | |||
Line 4: | Line 4: | ||
</hide> | </hide> | ||
==About== | ==About== | ||
− | In coding, a [[ | + | In coding, a [[delimiter-prefixed string]] is a string value that contains single-character-delimited substrings of variable length where the delimiting character is always included as the first character of the string. |
− | This | + | This eliminates the need to define or pass the delimiting character separately, which makes it easy to store lists of short strings as a single value. The only constraint this adds is that the delimiting character must not appear in any of the substrings; this technique is therefore most useful for predefined constants, where a character can be chosen that won't conflict with the substring values and hopefully will help to visually set the values apart. |
Examples: | Examples: | ||
* <code>"/one/two/three/four"</code> (dividing char = "/") | * <code>"/one/two/three/four"</code> (dividing char = "/") | ||
* <code>" Monday Tuesday Wednesday Thursday Friday Saturday Sunday"</code> (dividing char = space) | * <code>" Monday Tuesday Wednesday Thursday Friday Saturday Sunday"</code> (dividing char = space) |
Latest revision as of 23:11, 28 September 2019
About
In coding, a delimiter-prefixed string is a string value that contains single-character-delimited substrings of variable length where the delimiting character is always included as the first character of the string.
This eliminates the need to define or pass the delimiting character separately, which makes it easy to store lists of short strings as a single value. The only constraint this adds is that the delimiting character must not appear in any of the substrings; this technique is therefore most useful for predefined constants, where a character can be chosen that won't conflict with the substring values and hopefully will help to visually set the values apart.
Examples:
"/one/two/three/four"
(dividing char = "/")" Monday Tuesday Wednesday Thursday Friday Saturday Sunday"
(dividing char = space)