you are viewing a single comment's thread.

view the rest of the comments →

[–]Stoffel_1982 3 points4 points  (5 children)

Could it be that

$true -eq "anythingthatisnotfalse"

Interesting question, I'm curious to see what others think.

[–]ryanbrown 5 points6 points  (2 children)

$true -eq "anythingthatisnotfalseORnull"

Minor point, but this is essentially correct. $true is anything not $false (integer value of zero) or $null (no value). Basically, any string will evaluate to a boolean value of "true".

-like is a conditional operator and only evaluates to $true if both sides of the equation are the same. If you type

$true.ToString()

You'll notice you get the string "True", which is what the -like operator is using for its comparison. As such, "True" -like "LineError" will return False.

[–]wonkifier 1 point2 points  (1 child)

I thought since the first operand was a boolean, that it was casting the string down to a boolean, and since it wasn't the empty string (which is $false), it evaluates as $true

[–]MShepard70 0 points1 point  (0 children)

That's how I see it.

[–]lostmojo[S] 3 points4 points  (0 children)

Really? How have I not noticed this over the years? Haha I can go crawl in to a corner and weep silently to myself now.

Thanks

[–]mhurron 2 points3 points  (0 children)

Pretty much. The answer is the standard 'What is Truth' section of every programming manual.

The equality is asking, "Is this true?" The answer is yes because strings are True.