Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional specs for destructuring in for loops #1159

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions language/for_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
end
end

it "iterates over a list of arrays and destructures with an empty splat" do
for i, * in [[1,2]]
i.should == 1
end
end

it "iterates over a list of arrays and destructures with a splat" do
for i, *j in [[1,2]]
i.should == 1
j.should == [2]
end
end

it "iterates over a list of arrays and destructures with a splat and additional targets" do
for i, *j, k in [[1,2,3,4]]
i.should == 1
j.should == [2,3]
k.should == 4
end
end

it "iterates over an Hash passing each key-value pair to the block" do
k = 0
l = 0
Expand Down