Thanks to all responders. An enumerator really was not needed in my example
(coworkers started me down that wrong path).
I ended up using a.split(",").shift for clarity.

On Mon, Nov 24, 2014 at 5:05 PM, bruka <bruka / idatainc.com> wrote:

> I find this very confusing, and am not sure at all what you're asking.
> But here's my attempt at an answer.
>
> How is .map {|v| v} not the same as just .map() ? Array#map with no
> block will return an enumerator which should work fine. I've seen
> Array#cycle used often in this manner to get the enumerator. Why do
> you even need .map in there => a.split(";")[1..-1].join(",")?
>
>
> > 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"
>
> I can think of 10 ways of doing that that don't look half as
> complicated. Seems like 1-line solution obsession to me.
> Regex? a.gsub!(/^\w+\,/ , '' )
> Array#shift() ? Would be longer, but the intent is much clearer than
> a.split(",")[1..-1]
>
> Also BTW a.split(",")[1..-1] will return nil if 'a' is an empty
> string. So any method calls after that will crash.
>
> Just my 2 cents. But again, maybe I'm totally missing the issue.
>
> On Sat, Nov 22, 2014 at 4: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/>*