Project

General

Profile

Feature #14821

aditional arguments to yield_self

Added by DarkWiiPlayer (Dennis Fischer) over 2 years ago. Updated over 2 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:87382]

Description

Currently, yield_self only accepts a block as its single argument. I propose that it should also accept a series of additional arguments that get passed to the block after self

This is what I mean:

def yield_self(*args, &block)
  block.call(self, *args)
end

which would allow writing code like this

some_object.yield_self(:name, :surname, &sort_stuff).do_more_stuff()

instead of code like this

some_object.yield_self{|x| sort_stuff.call(x, :name, :surname).do_more_stuff()

This 1) is shorter 2) expresses intention rather than implementation.

Also available in: Atom PDF