[#70257] [Ruby trunk - Feature #11420] [Open] Introduce ID key table into MRI — ko1@...

Issue #11420 has been reported by Koichi Sasada.

11 messages 2015/08/06

[ruby-core:70473] [Ruby trunk - Feature #6373] public #self

From: a.y.chernenkov@...
Date: 2015-08-20 07:02:45 UTC
List: ruby-core #70473
Issue #6373 has been updated by Alexey Chernenkov.


-1

For me it would be better to accept #47 - it improves good old #tap and introduces a new #itself with block.

Copied here:

~~~
def tap
  yield self if block_given?
  self
end

def itself
  if block_given?
    yield self
  else
    self
  end
end
~~~

----------------------------------------
Feature #6373: public #self
https://bugs.ruby-lang.org/issues/6373#change-53878

* Author: Thomas Sawyer
* Status: Closed
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
This was recently suggested to me as an extension:

~~~ruby
class Object
  # An identity method that provides access to an object's 'self'.
  #
  # Example:
  #   [1,2,3,4,5,1,2,2,3].group_by(&:identity)
  #   #=> {1=>[1, 1], 2=>[2, 2, 2], 3=>[3, 3], 4=>[4], 5=>[5]}
  #
  def identity
    self
  end
end
~~~

First, is such a method commonly useful enough to warrant existence?

Second, it makes me wonder if #self should be a public method in general.


---Files--------------------------------
self.pdf (77.8 KB)
itself.diff (1.87 KB)


-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next