You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`Array[Y]`|`Array[X]`|`X` must be coercible to `Y`|
@@ -1973,6 +1974,16 @@ Whether a coercion is valid is determined from the source and target types durin
1973
1974
|`Enum`|`String`|`String` value must exactly match one of the enum's choice names |
1974
1975
|`String`|`Enum`| The enum choice is serialized to its choice name |
1975
1976
1977
+
###### String-to-Primitive Coercion
1978
+
1979
+
When a `String` is coerced to an `Int`, `Float`, or `Boolean`, leading and trailing whitespace is ignored and the remaining content is converted as follows:
1980
+
1981
+
* An `Int` conversion succeeds if the content represents a valid integer in the range of the `Int` type.
1982
+
* A `Float` conversion succeeds if the content represents a valid integer or floating point number in the range of the `Float` type.
1983
+
* A `Boolean` conversion succeeds if the content is `true` or `false`, compared case-insensitively.
1984
+
1985
+
If the content does not meet the requirements of the target type, the coercion fails with an error during dynamic evaluation.
1986
+
1976
1987
<details>
1977
1988
<summary>
1978
1989
Example: string_to_primitives.wdl
@@ -8984,7 +8995,7 @@ Example output:
8984
8995
Int read_int(File)
8985
8996
```
8986
8997
8987
-
Reads a file that contains a single line containing only an integer and (optional) whitespace. If the line contains a valid integer, that value is returned as an `Int`. If the file is empty or does not contain a single integer, an error is raised.
8998
+
Reads the contents of a file as a `String`and [coerces](#string-to-primitive-coercion) it to an `Int`. If the file is empty or its contents cannot be coerced to an `Int`, an error is raised.
8988
8999
8989
9000
**Parameters**
8990
9001
@@ -9033,7 +9044,7 @@ Example output:
9033
9044
Float read_float(File)
9034
9045
```
9035
9046
9036
-
Reads a file that contains only a numeric value and (optional) whitespace. If the line contains a valid floating point number, that value is returned as a `Float`. If the file is empty or does not contain a single float, an error is raised.
9047
+
Reads the contents of a file as a `String`and [coerces](#string-to-primitive-coercion) it to a `Float`. If the file is empty or its contents cannot be coerced to a `Float`, an error is raised.
9037
9048
9038
9049
**Parameters**
9039
9050
@@ -9085,7 +9096,7 @@ Example output:
9085
9096
Boolean read_boolean(File)
9086
9097
```
9087
9098
9088
-
Reads a file that contains a single line containing only a boolean value and (optional) whitespace. If the non-whitespace content of the line is "true" or "false", that value is returned as a `Boolean`. If the file is empty or does not contain a single boolean, an error is raised. The comparison is case- and whitespace-insensitive.
9099
+
Reads the contents of a file as a `String`and [coerces](#string-to-primitive-coercion) it to a `Boolean`. If the file is empty or its contents cannot be coerced to a `Boolean`, an error is raised.
0 commit comments