Other Functions
defined
Tests whether the given optional value is defined, i.e., has a non-None value.
Signatures
wdl
Boolean defined(X?)Parameters
X?: optional value of any type.
Returns
falseif the input value isNone, otherwisetrue.
Example
wdl
String? name = "Alice"
String? missing = None
Boolean has_name = defined(name)
# `has_name` now contains `true`.
Boolean has_missing = defined(missing)
# `has_missing` now contains `false`.
if (defined(name)) {
String greeting = "Hello, " + select_first([name])
# This code will execute because `name` is defined.
}length
Returns the length of the input argument as an Int:
- For an
Array[X]argument: the number of elements in the array. - For a
Map[X, Y]argument: the number of items in the map. - For an
Objectargument: the number of key-value pairs in the object. - For a
Stringargument: the number of characters in the string.
Signatures
wdl
Int length(Array[X]|Map[X, Y]|Object|String)Parameters
Array[X]|Map[X, Y]|Object|String: A collection or string whose elements are to be counted.
Returns
- The length of the collection/string as an
Int.
Example
wdl
Array[Int] xs = [1, 2, 3]
Map[String, Int] m = {"a": 1, "b": 2}
String s = "ABCDE"
Int xlen = length(xs)
# `xlen` now contains `3`.
Int mlen = length(m)
# `mlen` now contains `2`.
Int slen = length(s)
# `slen` now contains `5`.