D
Daniel Berger
Hi all,
I'm just messing around with a custom String class, so I did this to
string.c:
static VALUE rb_str_init(int argc, VALUE* argv, VALUE v_str){
VALUE v_orig;
rb_scan_args(argc, argv, "01", &v_orig);
if(RTEST(v_orig))
rb_str_replace(v_str, v_orig);
printf("Hello!\n");
return v_str;
}
I rebuilt Ruby and installed it without issue. But, the "Hello" only
prints if you use the long form of the constructor:
s1 = String.new('test') # "Hello!"
s2 = "test" # Nothing printed
What do I need to change to make the constructor shortcut work as
expected?
Thanks,
Dan
I'm just messing around with a custom String class, so I did this to
string.c:
static VALUE rb_str_init(int argc, VALUE* argv, VALUE v_str){
VALUE v_orig;
rb_scan_args(argc, argv, "01", &v_orig);
if(RTEST(v_orig))
rb_str_replace(v_str, v_orig);
printf("Hello!\n");
return v_str;
}
I rebuilt Ruby and installed it without issue. But, the "Hello" only
prints if you use the long form of the constructor:
s1 = String.new('test') # "Hello!"
s2 = "test" # Nothing printed
What do I need to change to make the constructor shortcut work as
expected?
Thanks,
Dan