Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add multiple assignment support to java.util.Collection's Fixes #459 #460

Merged
merged 1 commit into from

3 participants

Alex Tambellini Kevin Menard Charles Oliver Nutter
Alex Tambellini
Collaborator

No description provided.

Kevin Menard
Collaborator

Should this only work with java.util.List implementations? java.util.Set inherits from java.util.Collection, but Ruby doesn't exhibit the same multiple assignment behaviour with Sets, presumably because there is no ordering.

Alex Tambellini
Collaborator

@nirvdrum, what about a Queue where there is ordering but it is not a List?

Alex Tambellini
Collaborator

We'd also miss the SortedSet interface if we went List only. I feel like we should just do it for all collections since it will still work it just wont have any guarantees about order.

Kevin Menard
Collaborator

Ahh, more corner cases. I guess I don't have a strong issue with it being on java.util.Collection, other than it doesn't have 1:1 parity with Ruby's Set. Since #459 seemed to be about deviating behaviour, I figured I'd mention that this breaks in a different (probably less important) way.

Charles Oliver Nutter headius merged commit ff74833 into from
Charles Oliver Nutter
Owner

Good fix, I like it. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
16 spec/java_integration/interfaces/collection_spec.rb
View
@@ -0,0 +1,16 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "Classes that implement Collection" do
+ before do
+ @first_item = 'first'
+ @second_item = 'second'
+ @items = [@first_item, @second_item]
+ @collection = Java::JavaUtil::ArrayList.new(@items)
+ end
+
+ it "should support multiple assignment" do
+ first_item, second_item = @collection
+ first_item.should eql @first_item
+ second_item.should eql @second_item
+ end
+end
1  src/jruby/java/java_ext/java.util.rb
View
@@ -29,6 +29,7 @@ def to_a
# first
toArray.to_a
end
+ alias_method :to_ary, :to_a
end
module java::util::Enumeration
Something went wrong with that request. Please try again.