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

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

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

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

kares opened this issue Jul 29, 2016 · 3 comments

Comments

@kares
Copy link
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
Copy link
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
Copy link
Member Author

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
Copy link
Member Author

kares commented Aug 1, 2016

supported since ddf7fa1

@kares kares closed this as completed 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
Projects
None yet
Development

No branches or pull requests

2 participants