Messed up the code adapting it to example. This should work:

a = "a,b,c"
a.split(",")[1..-1].map {|v| v}.join(",") #=> "b,c"

Then again, I can do just fine without the map

a.split(",")[1..-1].join(",") #=> "b,c"

Still, any way to use ampersand shortcut without specifying a method to get
{|a| a} like &:foo gives {|a| a.foo }?


On Sat, Nov 22, 2014 at 11:32 AM, Jeremy Axelrod <axelrod.jeremy / gmail.com>
wrote:

> There's a bug in your code and the map function is just creating a copy of
> your array, i don't think that's your intended goal.
>
> About your last example, you wanna call join on the array, not use join in
> the block for map.
>
> Let us/me know if you have any questions.
>
> Sent from my phone.
>
>
>
> On 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*
>
>


-- 
-- 
*Augusts Bautra*


*Creative MobileKronvalda bulvaris 10, Riga**office: 00371 67227747*
*mobile: 00371 29957771*
*www.creo.mobi <http://www.creo.mobi/>*