Windows Powershell: Flattens arrays?

Been poking about in Windows Powershell. It's pretty sharp. I like it, and it's powerful as heck, but I am having to learn how to add to my toolset. Seems like I don't need it every day, but when I do, it's just the thing.

Anyway, I'd read about arrays in PS for sometime without really thinking about something: PS flattens arrays. No multidimensional arrays at all. Which, of course, confused me, given the power of MD arrays. So, why would they do that?

Only thing I can think of is that PS creates standard interfaces around "things" so that the code plugs together smoothly. Remember how a lot of your Micronauts fit? They did because they had that standard interface (I know if you are reading this you probably knew that, but I wanted to work in a reference to Micronauts; I loved those toys as a kid...I had tons....). I was reading in one of the Apress books on the subject, and the author points out that collections and arrays are exactly the same way and have exactly the same interface. Ergo, the array must be flattened.

Leastways, that's my best guess.

posted @ Wednesday, August 20, 2008 1:20 PM

Print

Comments on this entry:

# re: Windows Powershell: Flattens arrays?

Left by /\/\o\/\/ at 8/22/2008 2:41 PM
Gravatar
You can work with multidimensional arrays in PowerShell (or nested Hashtables, or Custom objects for that matter .

$a = (1,2),('a','b')
$a[0]
1
2

$a[1]
a
b

$a[1][1]
b
$a[1][0]
a

Greetings /\/\o\/\/
Comments have been closed on this topic.
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910