SHARE
TWEET

Untitled

a guest Oct 4th, 2013 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $letters = { 'A', 'B', 'C' }
  2.  
  3. $letters | % {
  4.  # Can I easily get the index of $_ here?
  5. }
  6.        
  7. PS> $a = 'a','b','c'
  8. PS> [array]::IndexOf($a, 'b')
  9. 1
  10. PS> [array]::IndexOf($a, 'c')
  11. 2
  12.        
  13. $letters = { 'A', 'B', 'C' }
  14. $letters | % {$i=0} {"Value:$_ Index:$i"; $i++}
  15.        
  16. $letters = { 'A', 'B', 'C'
  17. $letters | % {$counter = 0}{...;$counter++}
  18.        
  19. for($counter=0;$counter -lt $letters.Length;$counter++}{...}
  20.        
  21. 0..($letters.count-1) | foreach { "Value: {0}, Index: {1}" -f $letters[$_],$_}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top