In HCL, what is the result of this expression: `[for s in ["a", "b", "c"] : upper(s)]`?

Direct Answer (Verified)Reviewed by Sunny (Senior Cloud Engineer)

Correct Answer: A list: `["A", "B", "C"]`

A `for` expression with `[for item in collection : expression]` returns a **list**. Here it iterates the list `["a","b","c"]` and applies `upper()` to each element, producing `["A"...

Real Exam Scenario

In HCL, what is the result of this expression: `[for s in ["a", "b", "c"] : upper(s)]`?

✓ Correct Answer & Explanation

Correct Answer

A list: `["A", "B", "C"]`

Why This Answer Is Correct

A `for` expression with `[for item in collection : expression]` returns a **list**. Here it iterates the list `["a","b","c"]` and applies `upper()` to each element, producing `["A","B","C"]`. To produce a map, use `{for k, v in map : k => expression}`. To filter, add an `if` clause: `[for s in list : upper(s) if s != "b"]`.