Note that there are some explanatory texts on larger screens.

plurals
  1. POcan anyone explain the why the the 1st example gets different results than the following 2
    primarykey
    data
    text
    <pre> $b = (2,3) $myarray1 = @(,$b,$b) $myarray1[0].length #this will be 1 $myarray1[1].length $myarray2 = @( ,$b ,$b ) $myarray2[0].length #this will be 2 $myarray[1].length $myarray3 = @(,$b ,$b ) $myarray3[0].length #this will be 2 $myarray3[1].length </pre> <p><strong>UPDATE</strong></p> <p>I think on #powershell IRC we have worked it out, Here is another example that demonstrates the danger of breaking with the comma on the following line rather than the top line when listing multiple items in an array over multiple lines.</p> <pre> $b = (1..20) $a = @( $b, $b ,$b, $b, $b ,$b) for($i=0;$i -lt $a.length;$i++) { $a[$i].length } "--------" $a = @( $b, $b ,$b ,$b, $b ,$b) for($i=0;$i -lt $a.length;$i++) { $a[$i].length } </pre> <p>produces</p> <pre> 20 20 20 20 20 20 -------- 20 20 20 1 20 20 </pre> <p>In fact rather that using nested arrays that may complicate it here is a simple array of integers</p> <pre> $c = @( 1 , 2 , 3 , 4 ) for($i=0;$i -lt $c.length;$i++) { $c[$i].gettype() } "---------" $c = @( 1 , 2 , 3 , 4 ) for($i=0;$i -lt $c.length;$i++) { $c[$i].gettype() } </pre> <p>and the results</p> <pre> IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Int32 System.ValueType True True Int32 System.ValueType True True Int32 System.ValueType True True Int32 System.ValueType --------- True True Int32 System.ValueType True True Int32 System.ValueType True True Object[] System.Array True True Int32 System.ValueType </pre> <p>I'm curious how people will explain this. I think i understand it now, but would have trouble explaining it in a concise understandable fashion, though the above example goes somewhat towards that goal.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload