Ruby: RBasic Struct Reference

Ruby 3.4.3p32 (2025-04-14 revision d0b7e5b6a04bde21ca483d20a1546b28b401c2d4)

Public Member Functions | Data Fields
RBasic Struct Reference

Ruby object's base components. More...

`#include <rbasic.h>`

## Public Member Functions
| RBasic ()
| We need to define this explicit constructor because the field `klass` is const-qualified above, which effectively defines the implicit default constructor as "deleted" (as of C++11) – No way but to define one by ourselves.

## Data Fields
VALUE | flags
| Per-object flags.
const VALUE | klass
| Class of an object.

## Detailed Description

Ruby object's base components.

All Ruby objects have them in common.

Definition at line 61 of file rbasic.h.

## Constructor & Destructor Documentation

## ◆ RBasic()

RBasic::RBasic | ( |  | ) |
| inline

We need to define this explicit constructor because the field `klass` is const-qualified above, which effectively defines the implicit default constructor as "deleted" (as of C++11) – No way but to define one by ourselves.

Definition at line 100 of file rbasic.h.

Referenced by RBasic().

## Field Documentation

## ◆ flags

VALUE RBasic::flags

Per-object flags.

Each Ruby object has its own characteristics apart from its class. For instance, whether an object is frozen or not is not controlled by its class. This is where such properties are stored.

See also
  enum ruby_fl_type

Note
  This is VALUE rather than an enum for alignment purposes. Back in the 1990s there were no such thing like `_Alignas` in C.

Definition at line 75 of file rbasic.h.

Referenced by RBasic().

## ◆ klass

const VALUE RBasic::klass

Class of an object.

Every object has its class. Also, everything is an object in Ruby. This means classes are also objects. Classes have their own classes, classes of classes have their classes too, and it recursively continues forever.

Also note the `const` qualifier. In Ruby, an object cannot "change" its class.

Definition at line 86 of file rbasic.h.

Referenced by rb_data_object_alloc(), rb_data_object_make(), and RBasic().

The documentation for this struct was generated from the following file:

- include/ruby/internal/core/rbasic.h