Feature #13172
closedMethod that yields object to block and returns result
Description
Hi everyone!
There's a #tap method, that yields reciever to block and returns reciever itself.
I would like to see method, which would return yield's result.
I've seen many code samples that had a some "middle-variables" to store #some_method result.
Those variables are useless after few lines of code, so it would be great to create them in a limited scope (block).
P.S. I am very sorry for my english. I hope you understood me:D
P.P.S. I think there should be a better name than pass for such method
UPD. I've created a PR to see if #pass fits: https://github.com/ruby/ruby/pull/1521
Files
Updated by Nondv (Dmitry Non) almost 10 years ago
- Description updated (diff)
Updated by Nondv (Dmitry Non) almost 10 years ago
- Subject changed from Object#pass (yield object to block and return result) to Method that yields object to block and returns result
Updated by Nondv (Dmitry Non) almost 10 years ago
Oh, I forgot to notice. There's #instance_eval method, which do the job, but it evaluates block in object context, so it doesn't fit
Updated by Nondv (Dmitry Non) almost 10 years ago
- Tracker changed from Bug to Feature
Updated by phluid61 (Matthew Kerwin) almost 10 years ago
Updated by Nondv (Dmitry Non) almost 10 years ago
Updated by nobu (Nobuyoshi Nakada) almost 10 years ago
- Is duplicate of Feature #10095: Object#as added
Updated by nobu (Nobuyoshi Nakada) almost 10 years ago
- Is duplicate of Feature #11717: Object#trap -- pass object to block and return result added
Updated by nobu (Nobuyoshi Nakada) almost 10 years ago
- Is duplicate of Feature #12760: Optional block argument for `itself` added
Updated by Nondv (Dmitry Non) almost 10 years ago
- Description updated (diff)
Updated by Nondv (Dmitry Non) almost 10 years ago
- Description updated (diff)
Updated by Nondv (Dmitry Non) almost 10 years ago
- Description updated (diff)
Updated by Nondv (Dmitry Non) almost 10 years ago
- Description updated (diff)
Updated by Nondv (Dmitry Non) almost 10 years ago
- File method_pass.patch method_pass.patch added
.patch file
Updated by matz (Yukihiro Matsumoto) over 9 years ago
I don't think "pass" is a good name for it.
Matz.
Updated by nobu (Nobuyoshi Nakada) over 9 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r58528.
object.c: Kernel#yield_self
- object.c (rb_obj_yield_self): new method which yields the
receiver and returns the result.
[ruby-core:46320] [Feature #6721]