nerdexam
HashiCorp

TA-002-P · Question #135

Which of the following type of variable allows multiple values of several distinct types to be grouped together as a single value?

The correct answer is B. Object C. Tuple. Both Object and Tuple support grouping multiple values of different (distinct) types. An object groups named attributes each with their own specified type, e.g., object({ name = string, age = number }). A tuple is an ordered sequence where each element can have a different type,

Understand Terraform basics

Question

Which of the following type of variable allows multiple values of several distinct types to be grouped together as a single value?

Options

  • AMap
  • BObject
  • CTuple
  • DList

How the community answered

(53 responses)
  • A
    4% (2)
  • B
    91% (48)
  • D
    6% (3)

Explanation

Both Object and Tuple support grouping multiple values of different (distinct) types. An object groups named attributes each with their own specified type, e.g., object({ name = string, age = number }). A tuple is an ordered sequence where each element can have a different type, e.g., tuple([string, number, bool]). By contrast, a map (A) requires all values to be of the same type, and a list (D) also requires uniform element types. The key differentiator is that object and tuple are structural types that permit heterogeneous types.

Topics

#Terraform variables#Data types#Objects#Tuples

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice