summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-02 06:30:26 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-02 06:30:26 +0000
commit35c9feaeb72c1bf6c8642d05e9b0974649d12651 (patch)
treedb8464e9067708ad180f96b08a63c8bbf091e9e3 /array.c
parenta6157194a63e8e254f94b4ee3b7c9184b34aa3fc (diff)
* array.c (rb_ary_assoc): check and convert inner arrays (assocs)
using #to_ary. * hash.c (rb_hash_s_create): check and convert argument hash using #to_hash. * hash.c (rb_hash_s_create): Hash#[] now takes assocs as source of hash conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/array.c b/array.c
index 835e76b..44ca19a 100644
--- a/array.c
+++ b/array.c
@@ -2420,10 +2420,9 @@ rb_ary_assoc(ary, key)
VALUE v;
for (i = 0; i < RARRAY(ary)->len; ++i) {
- v = RARRAY(ary)->ptr[i];
- if (TYPE(v) == T_ARRAY &&
- RARRAY(v)->len > 0 &&
- rb_equal(RARRAY(v)->ptr[0], key))
+ v = rb_check_array_type(RARRAY_PTR(ary)[i]);
+ if (!NIL_P(v) && RARRAY(v)->len > 0 &&
+ rb_equal(RARRAY_PTR(v)[0], key))
return v;
}
return Qnil;