mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Enumerable#to_h with block and so on
[Feature #15143] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e76eebd79b
commit
abe75149d1
16 changed files with 243 additions and 30 deletions
|
@ -34,4 +34,11 @@ describe "Array#to_h" do
|
|||
it "does not accept arguments" do
|
||||
lambda { [].to_h(:a, :b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
it "converts [key, value] pairs returned by the block to a hash" do
|
||||
i = 0
|
||||
[:a, :b].to_h {|k| [k, i += 1]}.should == { a: 1, b: 2 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue