Java array (Enumerable) does not handle last() #4039

Closed
kares opened this Issue Jul 29, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@kares
Member

kares commented Jul 29, 2016

jruby-9.1.2.0 :001 > [1, 2, 3].to_java.is_a? ArrayJavaProxy
 => true 
jruby-9.1.2.0 :002 > [1, 2, 3].to_java.is_a? Enumerable
 => true 
jruby-9.1.2.0 :003 > [1, 2, 3].to_java.last
NoMethodError: undefined method `last' for java.lang.Object[1, 2, 3]@1139b2f3:#<Class:0x7a69b07>
    from (irb):3:in `<eval>'
    from org/jruby/RubyKernel.java:983:in `eval'
    from org/jruby/RubyKernel.java:1290:in `loop'
    from org/jruby/RubyKernel.java:1103:in `catch'
    from org/jruby/RubyKernel.java:1103:in `catch'
    from /opt/local/rvm/rubies/jruby-9.1.2.0/bin/irb:13:in `<top>'
jruby-9.1.2.0 :004 > [1, 2, 3].to_java.count
 => 3 
jruby-9.1.2.0 :005 > [1, 2, 3].to_java.count { |e| e>=2  }
 => 2 

same on 1.7.x

... which seems unintended or is it not ?!

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Jul 29, 2016

Member

@kares last is not in Enumerable although strangely first is. I think last is Ruby Array method specifically. Not sure if this matters or not since it is somewhat a reasonable method to consider to add.

Member

enebo commented Jul 29, 2016

@kares last is not in Enumerable although strangely first is. I think last is Ruby Array method specifically. Not sure if this matters or not since it is somewhat a reasonable method to consider to add.

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Jul 29, 2016

Member

@enebo right, thanks! I actually knew this a few weeks back ... seemed weird - why would it be removed :)
will most likely add last and last(count) just like Ruby's Array (and java.util.List) has.

Member

kares commented Jul 29, 2016

@enebo right, thanks! I actually knew this a few weeks back ... seemed weird - why would it be removed :)
will most likely add last and last(count) just like Ruby's Array (and java.util.List) has.

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Aug 1, 2016

Member

supported since ddf7fa1

Member

kares commented Aug 1, 2016

supported since ddf7fa1

@kares kares closed this Aug 1, 2016

@kares kares added this to the JRuby 9.1.3.0 milestone Aug 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment