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.
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)- A13% (6)
- B87% (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.
The statement accurately describes the distinct type characteristics of lists and objects in Terraform, making this choice incorrect.
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
Community Discussion
No community discussion yet for this question.