best type
In case the input parameter is a string, then it will be converted to the best type, depending on the contents. All non-string types (numerals, sets, dates, booleans voids) will be passed through without modifications Following rules apply for strings provided as parameters
Indirect parameter passing is disabled
1-2
No. | Type | Description |
---|---|---|
1 input |
valid types | Value Contents to be converted to best type. |
2 input |
boolean | Do sets If 'true', then string contents looking like set descriptions will be converted to sets Default value: false |
Type | Description |
---|---|
set | Result Value converted into best type |
values[] =
{ 1.2, date(today), true, { 1,2,{3,a} }, "Hello", // No conversions
"true", "True", // Only 'true' will be converted
"false", "False", // Only 'false' will be converted
"2020-04-17", "2020-04-07 22:30:00", "2020-04-07 22:30", // Time conversion if fully specified. 3rd exmaple si not converted
"{1,2,{3,A} }", // Converts to set
"1.2", "1E+3", // Converts to numbers
"0000-00-00" }; // Converts to blank date
for all ( values[], v[] )
{
n[] = best type( v[], true ); // 2nd set also asks to convert strings containing sets to sets.
echo("Value: ", n[], " Type: ", type(n[]) );
}
Value: 1.2 Type: numeral
Value: 2025-02-28 Type: date
Value: true Type: boolean
Value: {1,2,{3,'a'}} Type: set
Value: Hello Type: string
Value: true Type: boolean
Value: True Type: string
Value: false Type: boolean
Value: False Type: string
Value: 2020-04-17 Type: date
Value: 2020-04-07 22:30:00 Type: date
Value: 2020-04-07 22:30 Type: string
Value: {1,2,{3,'A'}} Type: set
Value: 1.2 Type: numeral
Value: 1E+3 Type: numeral
Value: Type: date