Add top_self "main" object #327

wants to merge 1 commit into


None yet

4 participants


Please review and let me know if this is acceptable.


I try to usr global variable instead of instance variable.

@matz matz added a commit that closed this pull request Sep 2, 2012
@matz matz introduce toplevel object main; close #327 fd3af6a
@matz matz closed this in fd3af6a Sep 2, 2012

It is mrb->object_class reference the correct way to add a method to the toplevel object main? For example:

mrb_state *mrb = mrb_open();
mrb_define_method(mrb, mrb->object_class, "sqrt", custom_sqrt, ARGS_REQ(1));
mruby member

If you want to add global methods (methods available everywhere in your program), yes.
If you want to add singleton methods to the toplevel object main, currently there's no way, right now.


I was trying to create a global method. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment