JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6125

Yielding a single object to a block with |a, b| arguments does not call #to_ary

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Assume that s is a method that yields a single object:

      def s(a)
        yield(a)
      end
      
      def somethingelse
        s(obj) {|a, b| [a, b]}
      end
      

      When somethingelse executes, MRI will call obj.toAry, and if toAry returns [:thing, :otherthing], a gets :thing and b gets :otherthing. In jruby, a gets obj, and b gets nil, and obj.toAry is not called.

      This is tested in rubyspec/language/block_spec.rb

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Appears to work fine as of 1.7pre2.

        Show
        Charles Oliver Nutter added a comment - Appears to work fine as of 1.7pre2.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Martin Harriman
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: