Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-16

Re: [PATCH v4 1/2] Documentation: fix linkgit references

From: Jeff King <hidden>
Date: 2016-06-16 02:19:11

Possibly related (same subject, not in this thread)

On Wed, May 04, 2016 at 11:54:52PM +0200, Ævar Arnfjörð Bjarmason wrote:
quoted
  my @files = map { chomp; $_ } `git ls-files`;
As a minor sidenote you can equivalently write that as:

    chomp(my @files = `git ls-files`);

I.e. chomp itself when given a list will chomp each item of the list.
So no need for a map.
Right, thanks, that is more readable. I use the map form reflexively
because I am often doing stuff like:

  my @list = do {
    open(my $fh, '<', $fn);
    map { chomp; $_ }
  };

(or replacing "do" with an actual function which is returning a
grotesque pipeline of grep/map, etc).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help