Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Struct.members
() -> ::Array[::Symbol]
StructClass::members → array_of_symbols
struct.c
View on GitHub ↗
static VALUE
rb_struct_s_members_m(VALUE klass)
{
VALUE members = rb_struct_s_members(klass);
return rb_ary_dup(members);
}
Returns the member names of the Struct descendant as an array:
Example
Customer = Struct.new(:name, :address, :zip) Customer.members # => [:name, :address, :zip]