Description
-
C:\PS> 12/31/07 -as [DateTime]
should beC:\PS> '12/31/07' -as [DateTime]
(LHS needs quoting) -
"The -as operator tries to convert the input object to the specified .NET Framework type. If it succeeds, it returns the converted object. It if fails, it returns nothing.": it would be more accurate to say "it returns
$null
". -
"The type operators always return a Boolean value" should either be "The Boolean type operators always return a Boolean value" or
-is
and-isnot
should be mentioned explicitly.
Consider rewriting the paragraph altogether; e.g.:
"
The type operators always operate on the input object as a whole. That is, if the input object happens to be a collection, it is the collection type that is tested, not the types of the collection's elements.
"
- The topic neglects to mention that if the LHS is a type that is derived from the RHS,
$True
is also returned (-is
) / the LHS is passed through (-as
); e.g.,
(Get-Item /) -is [System.IO.FileSystemInfo]
returns$True
, because the type of the LHS,[System.IO.DirectoryInfo]
, is derived from the RHS (type).
Version(s) of document impacted
- Impacts 6 document
- Impacts 5.1 document
- Impacts 5.0 document
- Impacts 4.0 document
- Impacts 3.0 document