I know Ruby has a map! method which do this. In PowerShell currently what I did is:
$new_array = @();
$array | % {
$new_array += <do something with the currently element $)>;
}
$array = $new_array;
I want to know the best way to do this. Thanks!
Simplest I can think of is
$_ + 1being the transformation I want.So you can do:
or
PS:
You can define a map function if you want:
Or write an extension method on System.Array: http://blogs.msdn.com/b/powershell/archive/2008/09/06/hate-add-member-powershell-s-adaptive-type-system.aspx