Actions
Feature #18736
openself-p for method chain
Feature #18736:
self-p for method chain
Status:
Open
Assignee:
-
Target version:
-
Description
You may want to check object with p method at the middle of a method chain.
Here is my recomendation.
class Object
def sp(method=nil, *args, &block)
if method
Kernel.p self.public_send(method, *args, &block)
elsif block_given?
Kernel.p block.call(self)
else
Kernel.p self
end
return self
end
end
Example of usage:
- check itself in the middle of a method-call
- output
- check its value in some string format
- output
- check its sum with an initial value
- output
- check its value with a
mapoperation
- output
- check its value connected in string
- output
Your brush-up comments are welcomed. thx.
Actions