summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-12-17 15:47:17 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-12-17 15:59:42 +0900
commitc03fa0e1b3acea696c8715a679915bb58b067403 (patch)
tree8aa010f631d83f3bfd03ba94af1e7f574d1dc994 /src/string.c
parentea71f1165bcae2e70b2811fbab270612b7ac5eea (diff)
downloadmruby-c03fa0e1b3acea696c8715a679915bb58b067403.tar.gz
mruby-c03fa0e1b3acea696c8715a679915bb58b067403.zip
Recover `String#to_str`; ref #4177
We have removed implicit conversion to strings using `to_str`. But some people still using `to_str` as a typical string method, i.e. they do string check by code like: `obj.respond_to?(:to_str)`. So we have recovered the method.
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
index 2668a2c85..52941473c 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2754,6 +2754,7 @@ mrb_init_string(mrb_state *mrb)
#endif
mrb_define_method(mrb, s, "to_i", mrb_str_to_i, MRB_ARGS_ANY()); /* 15.2.10.5.39 */
mrb_define_method(mrb, s, "to_s", mrb_str_to_s, MRB_ARGS_NONE()); /* 15.2.10.5.40 */
+ mrb_define_method(mrb, s, "to_str", mrb_str_to_s, MRB_ARGS_NONE());
mrb_define_method(mrb, s, "to_sym", mrb_str_intern, MRB_ARGS_NONE()); /* 15.2.10.5.41 */
mrb_define_method(mrb, s, "upcase", mrb_str_upcase, MRB_ARGS_NONE()); /* 15.2.10.5.42 */
mrb_define_method(mrb, s, "upcase!", mrb_str_upcase_bang, MRB_ARGS_NONE()); /* 15.2.10.5.43 */