Skip to content

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

@kares

Description

@kares
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 ?!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions