Skip to content

Commit

Permalink
add a note on when to use foreach instead of map
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
JeffBezanson committed Oct 26, 2015
1 parent da6e1f3 commit 8c10347
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,8 @@ doc"""
Call function `f` on each element of iterable `c`.
For multiple iterable arguments, `f` is called elementwise.
`foreach` should be used instead of `map` when the results of `f` are not
needed, for example in `foreach(println, array)`.
"""
foreach(f) = (f(); nothing)
foreach(f, itr) = (for x in itr; f(x); end; nothing)
Expand Down

0 comments on commit 8c10347

Please sign in to comment.