diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-09 12:27:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-09 12:27:26 +0000 |
commit | 29862685c0acf3a40c6b1f9e8780cbbd86cba658 (patch) | |
tree | 64813c6d3e206f9ad51009a640750f26ce9e7231 /test/ruby/test_hash.rb | |
parent | 50dbcf5f6d56b95fd1c240341b5b2615715b2720 (diff) | |
download | ruby-29862685c0acf3a40c6b1f9e8780cbbd86cba658.tar.gz |
dig
* array.c (rb_ary_dig): new method Array#dig.
* hash.c (rb_hash_dig): new method Hash#dig.
* object.c (rb_obj_dig): dig in nested arrays/hashes.
[Feature #11643]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r-- | test/ruby/test_hash.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index e8f0f87326..ee51c8ed7d 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1302,6 +1302,12 @@ class TestHash < Test::Unit::TestCase x = x end + def test_dig + h = @cls[a: @cls[b: [1, 2, 3]], c: 4] + assert_equal(1, h.dig(:a, :b, 0)) + assert_nil(h.dig(:c, 1)) + end + class TestSubHash < TestHash class SubHash < Hash def reject(*) |