Skip to content

sum method - undefined method 'last' for 1:Integer #7326

@djberg96

Description

@djberg96

jruby 9.3.6.0 (2.6.8) 2022-06-27 OpenJDK 64-Bit Server VM 14.0.2+12-46 on 14.0.2+12-46 +jit [x86_64-darwin]
MacOS 12.5.1 (Monterey)

I'm seeing a failure with each_slice + sum:

irb(main):001:0> w0 = 1; w1 = 2; w2 = 3;
=> 3
irb(main):002:0> index = [1,2,3]
=> [1, 2, 3]
irb(main):003:0> needed_bytes = (w0 + w1 + w2) * index.each_slice(2).sum(&:last)

With MRI this returns 30. With JRuby I see NoMethodError (undefined method 'last' for 1:Integer).

Initially spotted via gettalong/hexapdf#190

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions