Project

General

Profile

Actions

Feature #6721

closed

Object#yield_self

Added by alexeymuranov (Alexey Muranov) over 12 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:46320]

Description

I think the following method is missing from Ruby:

 class Object
   def yield_self(*args)
     yield(self, *args)
   end
 end

I do not know a good use case, but it looks very natural to me. It can be used in method chains.

What do you think? Is there an alternative?


Related issues 5 (0 open5 closed)

Related to Ruby master - Feature #7388: Object#embedRejectedmatz (Yukihiro Matsumoto)11/19/2012Actions
Related to Ruby master - Feature #6684: Object#doRejected07/02/2012Actions
Has duplicate Ruby master - Feature #11717: Object#trap -- pass object to block and return resultClosedActions
Has duplicate Ruby master - Feature #10095: Object#asClosedActions
Has duplicate Ruby master - Feature #12760: Optional block argument for `itself`ClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0