Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: cool way of manipulating array elements

by pemungkah (Priest)
on Sep 02, 2011 at 20:27 UTC ( #923924=note: print w/ replies, xml ) Need Help??


in reply to Re: cool way of manipulating array elements
in thread cool way of manipulating array elements

I wish I could upvote this multiple times. map is very cool, and can give you a marvelously compact syntax, but a simple foreach or while loop does the same thing and is (usually) easier to read.
  • Comment on Re^2: cool way of manipulating array elements

Replies are listed 'Best First'.
Re^3: cool way of manipulating array elements
by PrakashK (Pilgrim) on Sep 13, 2011 at 20:29 UTC

    I use map, not for its "compact syntax", but depending on the use case. This example, in my opinion, is the perfect use case for map: transform an array using some criteria and return a new array.

    for (or, foreach if you like) has its place, but I don't find it inherently more readable than map.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://923924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2016-06-26 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (327 votes). Check out past polls.