on-internet
← Community

Strange behavior for PowerShell Length after ForEach method

Stack Overflow ·

In official document it's mentioned that Length is one alias for Count, however I found one case that they behave differently. Besides, if I replace ForEach method with ForEach-Object, the Length will emit 3. Can anyone explain this? > (1..3).ForEach({$_}).Length 1 1 1 > (1..3).ForEach({$_}).Count 3

Comments

Sign in or sign up to comment and upvote.

No comments yet.