Hacker News new | past | comments | ask | show | jobs | submit login

More compact example (not to scare the POSIX people away :) ):

    0..1000000 | where {$_ % 10 -eq 0} | foreach {"Got Value: $_"}



The streaming behavior of the range operator is weird though. This is tested on PowerShell 7.4.1

    > 0..1000000000 | % { $_ }
    # Starts printing out numbers immediately
    > 0..1000000000
    # Hangs longer than I had patience to wait for
    > $x=0..100
    > $x.GetType()
    # IsPublic IsSerial Name     BaseType
    # -------- -------- ----     --------
    # True     True     Object[] System.Array
It's an array when I save it in a variable, but it's obviously not an array on the LHS of a pipe.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: