Function rb_singleton_class

Source
pub unsafe extern "C" fn rb_singleton_class(obj: VALUE) -> VALUE
Expand description

Finds or creates the singleton class of the passed object.

@param[out] obj Arbitrary ruby object. @exception rb_eTypeError obj cannot have its singleton class. @return A (possibly newly allocated) instance of ::rb_cClass. @post obj has its singleton class, which is the return value. @post In case obj is a class, the returned singleton class also has its own singleton class in order to keep consistency of the inheritance structure of metaclasses. @note A new singleton class will be created if obj did not have one. @note The singleton classes for ::RUBY_Qnil, ::RUBY_Qtrue, and ::RUBY_Qfalse are ::rb_cNilClass, ::rb_cTrueClass, and ::rb_cFalseClass respectively.

@internal

You can create a singleton class of a frozen object. Intentional or …?

§Nowadays there are wider range of objects who cannot have singleton classes than before. For instance some string instances cannot for some reason.

Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3