Intermediate
Ruby
Q65 / 100
What is the purpose of "Struct.new" in Ruby?
Correct! Well done.
Incorrect.
The correct answer is B) To quickly define a simple class with named attributes and automatically generated accessors
B
Correct Answer
To quickly define a simple class with named attributes and automatically generated accessors
Explanation
Struct.new(:a, :b) creates a new class with attribute accessors for :a and :b, plus useful methods like == and to_a, reducing boilerplate for simple data objects.
Progress
65/100