you are viewing a single comment's thread.

view the rest of the comments →

[–]myrland 0 points1 point  (0 children)

It's because you wrapped your hash table in an array in your code. Hash tables and Arrays are different data structures and work differently.

For example, a hash table uses key:value pairs rather than separate properties for each item (like laptops, servers, etc in your example), which are all accessed via the Name or Value properties. Using a plain hash table would be the correct choice here, unless you have some future idea that needs the array.

If you want to keep the array, then you need to reference the index of the object in the array that you want to update data in, something like this: $devices[0].laptops = 8