Difference between revisions of "delimiter-prefixed string"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(Created page with "<hide> page type::article thing type::coding pattern </hide> ==About== In coding, a segmented string is a string value that contains multiple substrings of variabl...")
 
Line 4: Line 4:
 
</hide>
 
</hide>
 
==About==
 
==About==
In coding, a [[segmented string]] is a string value that contains multiple substrings of variable length divided by a specific character. This is the most generally useful when the dividing character is defined as the first character in the string, so that the dividing character does not have to be set or passed separately. This makes it possible to store lists of short strings as a single value.
+
In coding, a [[segmented string]] is a string value that contains multiple substrings of variable length divided by a specific character.
 +
 
 +
This is the most generally useful when the dividing character is defined as the first character in the string, so that the dividing character does not have to be set or passed separately. This makes it possible to store lists of short strings as a single value. The only constraint this adds is that the dividing character must not appear in any of the substrings; this technique is therefore most useful for predefined constants, where a dividing character can be chosen that won't conflict with the substring values and hopefully will help to visually set the values apart.
  
 
Examples:
 
Examples:
* "/one/two/three/four"
+
* <code>"/one/two/three/four"</code> (dividing char = "/")
* "/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday"
+
* <code>" Monday Tuesday Wednesday Thursday Friday Saturday Sunday"</code> (dividing char = space)

Revision as of 19:53, 28 September 2019

About

In coding, a segmented string is a string value that contains multiple substrings of variable length divided by a specific character.

This is the most generally useful when the dividing character is defined as the first character in the string, so that the dividing character does not have to be set or passed separately. This makes it possible to store lists of short strings as a single value. The only constraint this adds is that the dividing character must not appear in any of the substrings; this technique is therefore most useful for predefined constants, where a dividing 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)