mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* object.c (sym_to_proc): imported Symbol#to_proc from ActiveSupprot.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
36d0a4eab0
commit
ac4d6ddfa3
2 changed files with 31 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Jun %-2d 04:38:20 2006 U-HUDIE\nobu,S-1-5-21-3746871489-166115513-3294629105-1005 <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (sym_to_proc): imported Symbol#to_proc from ActiveSupprot.
|
||||||
|
|
||||||
Sat Jun 10 18:02:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sat Jun 10 18:02:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* ext/bigdecimal/lib/bigdecimal/newton.rb (Newton::nlsolve): typo
|
* ext/bigdecimal/lib/bigdecimal/newton.rb (Newton::nlsolve): typo
|
||||||
|
|
26
object.c
26
object.c
|
@ -1055,6 +1055,31 @@ sym_to_sym(VALUE sym)
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
sym_call(VALUE args, VALUE sym)
|
||||||
|
{
|
||||||
|
VALUE obj = RARRAY(args)->ptr[0];
|
||||||
|
|
||||||
|
return rb_funcall(obj, SYM2ID(sym),
|
||||||
|
RARRAY(args)->len - 1,
|
||||||
|
RARRAY(args)->ptr + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* sym.to_proc
|
||||||
|
*
|
||||||
|
* Returns a _Proc_ object which respond to the given method by _sym_.
|
||||||
|
*
|
||||||
|
* (1..3).collect(&:to_s) #=> ["1", "2", "3"]
|
||||||
|
*/
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
sym_to_proc(VALUE sym)
|
||||||
|
{
|
||||||
|
return rb_proc_new(sym_call, sym);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
|
@ -2453,6 +2478,7 @@ Init_Object(void)
|
||||||
rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0);
|
rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0);
|
||||||
rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0);
|
rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0);
|
||||||
rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
|
rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
|
||||||
|
rb_define_method(rb_cSymbol, "to_proc", sym_to_proc, 0);
|
||||||
rb_define_method(rb_cSymbol, "===", rb_obj_equal, 1);
|
rb_define_method(rb_cSymbol, "===", rb_obj_equal, 1);
|
||||||
|
|
||||||
rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0);
|
rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue