Editing Topic: RCR273 Project: RCR | RCRchive home

RCR 273: Enumerable#inject_with

submitted by ummaycoc on Wed Aug 04 2004 07:52:45 AM -0700

Status: pending


Abstract

Just lets you inject with any method that takes a block...

Problem

Blocks are everywhere. Why not inject with anything?

Proposal

I propose adding an inject_with method to Enumerable. This way, things that might not actually be `injectable' can be...

Analysis

This is simple. No clue what to put here.

Implementation

module Enumerable def Enumerable.inject_with(object, sym, id, *args) object.send(sym, *args) {|*values| id = yield id, *values } id end end


Back to RCRchive.


RCR Submission page and RCRchive powered by Ruby, Apache, RuWiki (modified), and RubLog