There was an error while loading. Please reload this page.
:sym => val
sym: val
1 parent e31869f commit baeeb5eCopy full SHA for baeeb5e
1 file changed
src/hash.c
@@ -1858,11 +1858,18 @@ mrb_hash_to_s(mrb_state *mrb, mrb_value self)
1858
struct RHash *h = mrb_hash_ptr(self);
1859
H_EACH(h, entry) {
1860
if (i++ > 0) mrb_str_cat_lit(mrb, ret, ", ");
1861
- H_CHECK_MODIFIED(mrb, h) {
1862
- mrb_str_cat_str(mrb, ret, mrb_inspect(mrb, entry->key));
+ if (mrb_symbol_p(entry->key)) {
+ mrb_str_cat_str(mrb, ret, mrb_obj_as_string(mrb, entry->key));
1863
+ mrb_gc_arena_restore(mrb, ai);
1864
+ mrb_str_cat_lit(mrb, ret, ": ");
1865
+ }
1866
+ else {
1867
+ H_CHECK_MODIFIED(mrb, h) {
1868
+ mrb_str_cat_str(mrb, ret, mrb_inspect(mrb, entry->key));
1869
1870
1871
+ mrb_str_cat_lit(mrb, ret, " => ");
1872
}
- mrb_gc_arena_restore(mrb, ai);
- mrb_str_cat_lit(mrb, ret, " => ");
1873
H_CHECK_MODIFIED(mrb, h) {
1874
mrb_str_cat_str(mrb, ret, mrb_inspect(mrb, entry->val));
1875
0 commit comments