Strings
Basic string operations.
The string type comes with 3 operators:
  • length: returns the length of the string
  • slice: returns a subset of a string:
    • the first argument is the offset (starting from 0)
    • the second argument is the length of the subset
  • concat: returns the concatenation two strings
  • to_string : converts a nat value to a string
1
effect {
2
var s1 = "this is ";
3
var s2 = "a string";
4
if slice(s2,2,6) = "string" then transfer 1tz to dev;
5
if concat(s1,s2) = "this is a string" then transfer 1tz to dev;
6
if length(s1) = 8 then transfer 1tz to dev;
7
if to_string(5) = "5" then transfer 1tz to dev;
8
}
Copied!
The string type supports the 6 comparison operators = <= >= < > <>.
Last modified 1yr ago
Export as PDF
Copy link
Edit on GitHub