mrb_class_defined

Function mrb_class_defined 

Source
pub unsafe extern "C" fn mrb_class_defined(
    mrb: *mut mrb_state,
    name: *const c_char,
) -> mrb_bool
Expand description

Returns an mrb_bool. True if class was defined, and false if the class was not defined.

Example: void mrb_example_gem_init(mrb_state* mrb) { struct RClass *example_class; mrb_bool cd;

  example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
  cd = mrb_class_defined(mrb, "ExampleClass");

  // If mrb_class_defined returns TRUE then puts "True"
  // If mrb_class_defined returns FALSE then puts "False"
  if (cd) {
    puts("True");
  }
  else {
    puts("False");
  }
 }

@param mrb The current mruby state. @param name A string representing the name of the class. @return mrb_bool A boolean value.