Project

General

Profile

Actions

Feature #12380

open

`Struct` as a subclass of `Class`

Added by sawa (Tsuyoshi Sawada) over 8 years ago. Updated over 8 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:75500]

Description

This issue is somewhat of the same flavor as #12374.

Struct has a constructor that creates a class:

Struct.new(:foo)
# => #<Class:0x007f605f892cb0>

and this is the same situation with Class.

Class.new
# => #<Class:0x007f605f70c788>

Hence, most naturally, Struct should be a subclass of Class. But in reality, it isn't:

Struct.ancestors
# => [Struct, Enumerable, Object, Kernel, BasicObject]

The current structure around Struct is counter-intuitive to me.

I propose that either Struct should be redefined as a subclass of Class, or a new class StructClass should be introduced as a subclass of Class, and take over the functionality of Struct.

Actions

Also available in: Atom PDF

Like0
Like0Like0