String
A very useful data type representing a series of characters, e.g. an email address, the first name of a user, etc.
"Hello World!" $myStringVar
myStringVar ?
Strings like Buffers are also supporting addition operator <<<+>>>. Using this we can quickly appened two strings together,
"Hello" + " World!" ? // Hello World!
Using value <<<"">>> or <<<''>>> without any extra hex number, lets us define an empty string value.
"" ? // ""
'' ? // ''
For the time being, simorg doesn't differnetiate between <<<"">>> and <<<''>>> and considers both of them valid string wrappers. It actually helps you to use these characters inside string values more easily,
'"Double Quotation" in my string' ? // "Double Quotation" in my string
Othewise you could use the escape character <<<>>>.
"\"Double Quotation\" in my string" ? // "Double Quotation" in my string
Special Values
Using escape sequence, we can have access to special formating values including,
- <<<\n>>> End of the line.
- <<<\r>>> Same as End of the line. For compatibility reasons it may be used beside <<<\n>>>.
- <<<\t>>> A tab space sequence. Inserts horizontal tab character.
$$$AlertBox type=INFO title=More Utilities message=Simorg stl includes a dedicated library for Strings, providing more advanced operations.$$$
$$$AlertBox type=INFO title=Type Coercion message=Strings actively participate in type coercion if they are used beside relational or arithmetic operators and the other value is a Number. Engine tries to automatically convert String to Number if needed.$$$
Embedding values
Embedding a value inside a string is quite handly using <<<{}>>> placeholder,
100 "number {} is now embedded" ?
Using a <<<>>> before <<<{}>>> this behavior will be skipped.
100 "using \{} without embedding " ?
$$$AlertBox type=INFO title=Multi-Placeholder Support message=The support of multi-embedded values will be added in future versions.$$$
For more advanced formatting logics please check <<<string>>> plugin which is part of simorg Standard Libraries (STL).