From 1b000cd303d56d2fb649c5aea85fa99ca7547a3a Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 14 Feb 2007 04:57:25 +0000 Subject: * re.c (reg_operand): allow symbols to be operands for regular expression matches. * string.c (Init_String): allow Symbol#===. * lib/date/format.rb (Date::Format::Bag::to_hash): string added prefixes. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'string.c') diff --git a/string.c b/string.c index 89e88544c..17e392781 100644 --- a/string.c +++ b/string.c @@ -4809,6 +4809,13 @@ sym_match(VALUE sym, VALUE other) return rb_str_match(rb_sym_to_s(sym), other); } +static VALUE +sym_eqq(VALUE sym, VALUE other) +{ + if (sym == other) return Qtrue; + return rb_str_equal(rb_sym_to_s(sym), other); +} + static VALUE sym_aref(int argc, VALUE *argv, VALUE sym) { @@ -5051,6 +5058,7 @@ Init_String(void) rb_define_method(rb_cSymbol, "<=>", sym_cmp, 1); rb_define_method(rb_cSymbol, "casecmp", sym_casecmp, 1); rb_define_method(rb_cSymbol, "=~", sym_match, 1); + rb_define_method(rb_cSymbol, "===", sym_eqq, 1); rb_define_method(rb_cSymbol, "[]", sym_aref, -1); rb_define_method(rb_cSymbol, "slice", sym_aref, -1); -- cgit