Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can you give an example of where/how? I imagine you don't get caught out writing Bash scripts like:

    grep -e,-i,'\bneedle\b',file.txt | cut -F,2,-d,':'
Because that's so contextually distinct from Python/JavaScript/Ruby; in shells (and APL, J, LISPs), arrays of commands and their arguments are space separated rather than comma separated. Similar in PowerShell, where it looks like shell it tends to work like shell:

    get-childitem -Path c:\ -Filter *.txt -Force
Where it looks like scripting language it tends to work like one:

    $host.ui.WriteLine('Green', 'Yellow', 'Hi')


With functions

  function Get-Something {
    Param (
      [Parameter(Mandatory=$true, Position=0)]
      [string] $Name,
      [Parameter(Mandatory=$true, Position=1)]
      [int] $Id
    )
    # Write the output to the console
    Write-Output "Name: $Name, Id: $Id"
  }

  Get-Something "Alice" 42
If you were to call

  Get-Something("Alice", 42)
It would pass "Alice", 42 to the first parameter.

You can use named parameters to get round this, e.g.

  Get-Something -Name "Alice" -Id 42
Still a bit of a gotcha!




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

Search: