Skip to content

If-else blocks and array types #5

@SergeyTeplyakov

Description

@SergeyTeplyakov

PowerShell drives me nuts (I hope I missing something here).

Consider following code:

$var = $True

$foo = if ($var) {@(, 1)}

$foo # 1
$foo.GetType().FullName #System.Int32

$foo = @(, 1)

$foo # 1
$foo.GetTYpe().FullName #System.Object[]

Clearly that behavior should be the same. Right? But not exactly. Here is an output:

1
System.Int32
1
System.Object[]

I would say that this is a bug, not a trap!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions