Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add demo for Array#traverse :test:
  • Loading branch information
anithri committed Apr 19, 2015
1 parent c8c0b6a commit 14212c7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions demo/core/array/traverse.md
@@ -0,0 +1,20 @@
## Array#traverse

require 'facets/array/traverse'

Construct a new array created by traversing the array and its sub-arrays,
executing the given block on the elements.

h = ['A', 'B', ['X', 'Y']]
g = h.traverse{ |e| e.downcase }
g.assert = ['a','b',['x', 'y']]

## Array#traverse!

Like #traverse, but will change the array in place.

h = ['A', 'B', ['X', 'Y']]
h.traverse!{ |e| e.downcase }
h.assert = ['a','b',['x', 'y']]

0 comments on commit 14212c7

Please sign in to comment.