Skip to content

Commit 0787f89

Browse files
authored
Merge pull request #42 from takai/multiple_assignment
Alias to_ary for multiple assignment
2 parents 53c724b + 7a05aff commit 0787f89

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ext/pycall/pycall.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,6 +2078,7 @@ init_tuple(void)
20782078
rb_define_singleton_method(cTuple, "new", pycall_tuple_s_new, -1);
20792079
rb_define_method(cTuple, "length", pycall_tuple_length, 0);
20802080
rb_define_method(cTuple, "to_a", pycall_tuple_to_a, 0);
2081+
rb_define_alias(cTuple, "to_ary", "to_a");
20812082
}
20822083

20832084
void

spec/pycall/tuple_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ module PyCall
2222
end
2323
end
2424

25+
describe '#to_ary' do
26+
it 'is used for multiple assignment' do
27+
(a1, a2, a3), (b1, b2, b3) = Tuple.new(subject, subject)
28+
expect([a1, a2, a3]).to eq([1, 2, 3])
29+
expect([b1, b2, b3]).to eq([1, 2, 3])
30+
end
31+
end
32+
2533
describe '#inspect' do
2634
pending
2735
end

0 commit comments

Comments
 (0)