core/src/main/java/org/jruby/RubyEnumerable.java
public static IRubyObject takeItems(ThreadContext context, IRubyObject enumerable) {
        final RubyArray array = context.runtime.newArray();
        synchronized (array) {
            callEach(context, eachSite(context), enumerable, Signature.ONE_ARGUMENT, new BlockCallback() {
                public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                    return call(ctx, packEnumValues(ctx, largs), blk);
                }
                @Override
                public IRubyObject call(ThreadContext ctx, IRubyObject larg, Block blk) {
                    array.append(larg);
                    return larg;
                }
                @Override
                public IRubyObject call(ThreadContext ctx, IRubyObject larg) {
                    array.append(larg);
                    return larg;
                }
            });
        }

        return array;
    }
/**
     * Take all items from the given enumerable and insert them into a new array.
     *
     * See take_items() in array.c.
     *
     * @param context current context
     * @param enumerable object from which to take
     * @return an array of the object's elements
     */
Take all items from the given enumerable and insert them into a new array.

@param context current context
@param enumerable object from which to take
@return an array of the object's elements
Take all items from the given enumerable and insert them into a new array . @param context current context @param enumerable object from which to take @return an array of the object ' s elements
public static IRubyObject takeItems(ThreadContext context, IRubyObject enumerable) {
        final RubyArray array = context.runtime.newArray();
        synchronized (array) {
            callEach(context, eachSite(context), enumerable, Signature.ONE_ARGUMENT, new BlockCallback() {
                public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                    return call(ctx, packEnumValues(ctx, largs), blk);
                }
                @Override
                public IRubyObject call(ThreadContext ctx, IRubyObject larg, Block blk) {
                    array.append(larg);
                    return larg;
                }
                @Override
                public IRubyObject call(ThreadContext ctx, IRubyObject larg) {
                    array.append(larg);
                    return larg;
                }
            });
        }
        return array;
    }
public static IRubyObject takeItems ( ThreadContext context , IRubyObject enumerable ) { final RubyArray array = context . runtime . newArray ( ) ; synchronized ( array ) { callEach ( context , eachSite ( context ) , enumerable , Signature . ONE_ARGUMENT , new BlockCallback ( ) { public IRubyObject call ( ThreadContext ctx , IRubyObject [ ] largs , Block blk ) { return call ( ctx , packEnumValues ( ctx , largs ) , blk ) ; } @ Override public IRubyObject call ( ThreadContext ctx , IRubyObject larg , Block blk ) { array . append ( larg ) ; return larg ; } @ Override public IRubyObject call ( ThreadContext ctx , IRubyObject larg ) { array . append ( larg ) ; return larg ; } } ) ; } return array ; }
Take all items from the given enumerable and insert them into a new array.
Take all items from the given enumerable and insert them into a new array .