I am looking for a function which can get me all the keys from hash or I can loop through the hash to retrieve single key at a time.
Currently I am hardcoding key
VALUE option = rb_hash_aref(options, rb_str_new2("some_key"));
I am looking for a function which can get me all the keys from hash or I can loop through the hash to retrieve single key at a time.
Currently I am hardcoding key
VALUE option = rb_hash_aref(options, rb_str_new2("some_key"));
 
    
     
    
    You can iterate over the key/value pairs with a callback function using rb_hash_foreach (blog post w/an example):
void rb_hash_foreach(VALUE, int (*)(ANYARGS), VALUE);
There is an rb_hash_keys in MRI, but it's not in any header files it seems, so using it may be risky.
 
    
    You could always make a call to the Ruby method itself:
VALUE keys = rb_funcall(hash, rb_intern("keys"), 0)
