Skip to content

Instantly share code, notes, and snippets.

@dmalikov
Last active September 5, 2015 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmalikov/ab8089754ef86a72497a to your computer and use it in GitHub Desktop.
Save dmalikov/ab8089754ef86a72497a to your computer and use it in GitHub Desktop.
Meanwhile on the Planet of Adequate Programming Languages
################## PART ONE
> ("a" + "b" * 3).length
4
> ("a" + , "b" * 3).length
6
################## PART TWO
> if (2 > 1) { echo "two is larger than one" } else { echo "no it is not" }
no it is not
################## PART THREE
> if ("this string contains letter A" -contains "A") { echo "yep" } else { echo "but actually it does not" }
but actually it does not
################## PART FOUR
$ cat test.ps1
function add([int] $x, [int] $y) {
return $x + $y
}
Write-Host (add(1,2))
$ powershell ./test.ps1
add : Cannot process argument transformation on parameter 'x'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32".
At test.ps1:5 char:16
+ Write-Host (add(1,2))
+ ~~~~~
+ CategoryInfo : InvalidData: (:) [add], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,add
@RamblingCookieMonster
Copy link

Hi!

If you plan to use PowerShell, I would recommend spending some time learning it. Every language will break in amusing ways if you make assumptions, rather than learn the syntax.

No offense, even very bright folks like Helge Klein have made these assumptions.

Cheers!

@dmalikov
Copy link
Author

dmalikov commented Sep 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment