diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-10-21 09:00:02 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-10-21 09:00:02 +0000 |
commit | 5b014a7427ef87fecb54c368cf3fe1efabb03f03 (patch) | |
tree | a2f8e5c4ef38a997e4cc3cc10ae136748b8890d9 /object.c | |
parent | 73f94bb851588f04e5189d37544e87884fc489c7 (diff) | |
download | ruby-5b014a7427ef87fecb54c368cf3fe1efabb03f03.tar.gz |
* bin/erb (ERB::Main::run): typo fixed. [ruby-core:06337]
* env.h: move struct METHOD and struct BLOCK from eval.c to
support NodeWrap and ParseTree.
* rubysig.h (CHECK_INTS): prevent signal handler to run during
critical section. [ruby-core:04039]
* eval.c (load_wait): need not to call rb_thread_schedule()
explicitly. [ruby-core:04039]
* eval.c (rb_thread_schedule): clear rb_thread_critical.
[ruby-core:04039]
* eval.c (rb_obj_instance_exec): create instance_exec and
module_exec which pass arguments to the block.
* eval.c (rb_f_funcall): rename fcall to funcall to follow
tradition.
* st.c (st_free_table): do not call free() but xfree().
[ruby-core:06205]
* eval.c (splat_value): call rb_Array() to convert svalue to
values. [ruby-dev:27397]
* lib/cgi.rb (CGI::Cookie::parse): Cookies from Nokia devices may
not be parsed correctly. A patch from August Z. Flatby
(augustzf) in [ruby-Patches-2595]. [ruby-core:06183]
* object.c (rb_Array): Array() to raise error for objects without
to_ary, nor to_a.
* object.c (nil_to_a): revert NilClass#to_a.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -729,6 +729,22 @@ nil_to_s(VALUE obj) /* * call-seq: + * nil.to_a => [] + * + * Always returns an empty array. + * + * nil.to_a #=> [] + */ + +static VALUE +nil_to_a(obj) + VALUE obj; +{ + return rb_ary_new2(0); +} + +/* + * call-seq: * nil.inspect => "nil" * * Always returns the string "nil". @@ -2236,10 +2252,7 @@ rb_Array(VALUE val) VALUE tmp = rb_check_array_type(val); if (NIL_P(tmp)) { - tmp = rb_check_convert_type(val, T_ARRAY, "Array", "to_a"); - if (NIL_P(tmp)) { - return rb_ary_new3(1, val); - } + return rb_convert_type(val, T_ARRAY, "Array", "to_a"); } return tmp; } @@ -2250,8 +2263,6 @@ rb_Array(VALUE val) * * Returns <i>arg</i> as an <code>Array</code>. First tries to call * <i>arg</i><code>.to_ary</code>, then <i>arg</i><code>.to_a</code>. - * If both fail, creates a single element array containing <i>arg</i> - * (unless <i>arg</i> is <code>nil</code>). * * Array(1..5) #=> [1, 2, 3, 4, 5] */ @@ -2433,6 +2444,7 @@ Init_Object(void) rb_define_method(rb_cNilClass, "to_i", nil_to_i, 0); rb_define_method(rb_cNilClass, "to_f", nil_to_f, 0); rb_define_method(rb_cNilClass, "to_s", nil_to_s, 0); + rb_define_method(rb_cNilClass, "to_a", nil_to_a, 0); rb_define_method(rb_cNilClass, "inspect", nil_inspect, 0); rb_define_method(rb_cNilClass, "&", false_and, 1); rb_define_method(rb_cNilClass, "|", false_or, 1); |