diff --git a/demo/core/array/traverse.md b/demo/core/array/traverse.md new file mode 100644 index 00000000..8ec6ce8f --- /dev/null +++ b/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']] + +