diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-14 04:57:25 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-14 04:57:25 +0000 |
commit | 3098d80818c9fbaa3b5ae392f7fad319e7a65323 (patch) | |
tree | d1529e27a49d21e0d58175afae89df34ddec1dc7 /string.c | |
parent | f2586498f3bb38310f039e7532c034011e2aef82 (diff) | |
download | ruby-3098d80818c9fbaa3b5ae392f7fad319e7a65323.tar.gz |
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@11723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -4810,6 +4810,13 @@ sym_match(VALUE sym, VALUE 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) { return rb_str_aref_m(argc, argv, rb_sym_to_s(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); |