Other functions
2 functions on this page
Boolean defined(X?)
Tests whether the given optional value is defined, i.e., has a non-None value.
- 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.
}Int length(Array[X]|Map[X, Y]|Object|String)
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 Object argument: the number of key-value pairs in the object. - For a String argument: the number of characters in the string.
- 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`.