Skip to content

Object#identity #63

Closed
wants to merge 4 commits into from

4 participants

@citizen428

I know this seems like a stupid addition, but every time I have something to use something like { |foo| foo } I wish for a method (isn't (&:identity) much nicer?).

I know the name is a bit long, but the more common id is blocked by the deprecated Object#id. I toyed with it for a bit (collection.group_by(&:it)) but didn't find that entirely convincing either. Defining Object#self works, but I thought that might lead to confusion...

@citizen428

Oh damnit, another pull request that's a complete mess. :-( That's what I get for putting the previous change in master. Sorry, maybe that's a motivation to pull faster ;-)

@trans
Rubyworks member
trans commented Apr 27, 2012

Let me think about the name.

@LavirtheWhiolet

May be id_func?

@bitherder

How about #itself ?

@citizen428

In my own extensions library I went with #it in the end.

@LavirtheWhiolet

I vote for "identity".

@trans
Rubyworks member
trans commented Jul 29, 2012

I'm trying to hold out for an official decision for ruby core team. Unfortunately they have a nack for prolonging even the most basic decisions :-(

@citizen428

@trans When/how did ruby-core get involved in this?

@trans
Rubyworks member
trans commented Jan 7, 2014

Update on this. Looks like it will be called #itself and eventually be part of Ruby proper. Good job Citizen 482! 👍 Til then, I will add it to Facets.

@trans trans closed this Jan 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.