About having an ampersand-colon version of the { |x| x } block, it seems
<https://bugs.ruby-lang.org/issues/6373> that it will be available in
vanilla Ruby when 2.2 lands:

[1,2,3,4,5,1,2,2,3].group_by(&:itself)
#=> {1=>[1, 1], 2=>[2, 2, 2], 3=>[3, 3], 4=>[4], 5=>[5]}

On Mon, Nov 24, 2014 at 7:52 PM, Martin DeMello <martindemello / gmail.com>
wrote:

> Several functional languages define an identity function (usually called
> `id`, such that id(x) = x) for this exact purpose (i.e. passing it into
> contexts where a function is needed, but you don't really want to do
> anything to x). As other people have pointed out, you don't need it here,
> since map itself defaults to doing nothing if you don't pass it a function,
> but in general it does sometimes help with readability to define id and
> then use it in your code, even if the definition adds a few more lines of
> code to your program.
>
> martin
>
> On Sat, Nov 22, 2014 at 1:14 AM, Augusts Bautra <augusts / creo.mobi> wrote:
>
>> So these are equivalent:
>>
>> something {|i| i.foo }
>> something(&:foo)
>>
>> But say I want to cut off the first value of a comma-separated line:
>>
>> a = "a,b,c"
>> a.split(";")[1..-1].map {|v| v}.join(";") #=> "b;c"
>>
>> Can I somehow use ampersand (or to_proc) to have a shorthand of {|v| v}
>> Any way to use something like this?
>>
>> a.split(";")[1..-1].map&join(";")
>>
>> Thanks,
>> --
>> *Augusts Bautra*
>>
>>
>> *Creative Mobile*
>>
>
>


-- 
Demian Ferreiro