nerdexam
HashiCorp

TA-002-P · Question #112

True or False: A list(...) contain a number of values of the same type while an object(...) can contain a number of values of different types.

The correct answer is B. True. Terraform's type system distinguishes between lists, which hold values of a consistent type, and objects, which can contain named attributes of varying types.

Understand Terraform basics

Question

True or False: A list(...) contain a number of values of the same type while an object(...) can contain a number of values of different types.

Options

  • AFalse
  • BTrue

How the community answered

(46 responses)
  • A
    13% (6)
  • B
    87% (40)

Why each option

Terraform's type system distinguishes between lists, which hold values of a consistent type, and objects, which can contain named attributes of varying types.

AFalse

The statement accurately describes the distinct type characteristics of lists and objects in Terraform, making this choice incorrect.

BTrueCorrect

In Terraform, a `list(...)` is a sequence where all elements must be of the same type, while an `object(...)` is a structured collection of named attributes, and each attribute can indeed have a different type.

Concept tested: Terraform list and object types

Source: https://developer.hashicorp.com/terraform/language/expressions/types#collection-types

Topics

#Data Types#HCL#Lists#Objects

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice