{"action":"created","issue":{"url":"https://api.github.com/repos/PoshCode/PowerShellPracticeAndStyle/issues/67","repository_url":"https://api.github.com/repos/PoshCode/PowerShellPracticeAndStyle","labels_url":"https://api.github.com/repos/PoshCode/PowerShellPracticeAndStyle/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/PoshCode/PowerShellPracticeAndStyle/issues/67/comments","events_url":"https://api.github.com/repos/PoshCode/PowerShellPracticeAndStyle/issues/67/events","html_url":"https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/67","id":170461666,"number":67,"title":"Should Parameters Always Have Default Values?","user":{"login":"Jaykul","id":192942,"avatar_url":"https://avatars.githubusercontent.com/u/192942?v=3","gravatar_id":"","url":"https://api.github.com/users/Jaykul","html_url":"https://github.com/Jaykul","followers_url":"https://api.github.com/users/Jaykul/followers","following_url":"https://api.github.com/users/Jaykul/following{/other_user}","gists_url":"https://api.github.com/users/Jaykul/gists{/gist_id}","starred_url":"https://api.github.com/users/Jaykul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jaykul/subscriptions","organizations_url":"https://api.github.com/users/Jaykul/orgs","repos_url":"https://api.github.com/users/Jaykul/repos","events_url":"https://api.github.com/users/Jaykul/events{/privacy}","received_events_url":"https://api.github.com/users/Jaykul/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-08-10T16:34:00Z","updated_at":"2016-08-10T16:54:41Z","closed_at":null,"body":"I've already [written about this](https://github.com/PowerShell/PSScriptAnalyzer/issues/362), but it's probably worth having this conversation here.\r\n\r\nFunction parameters are **always** automatically defined in the local scope _and initialized by PowerShell_ to their default value (the equivalent of null -- which comes out as an empty string or a zero for numerical values, or a default struct, etc).\r\n\r\nThis happens even when they are part of an unused parameter set.\r\n\r\nThere is, in my opinion, nothing to be gained in setting them yourself -- unless you actually need them to default to something other than $null.\r\n\r\nIf anything, this should be warned against for performance reasons, and because people frequently provide default values on mandatory parameters (which can be misleading and even invalid defaults, since they're not used). \r\n\r\nAs with C# and most other programming languages, initializing a variable to it's default value is just extra work that accomplishes nothing. It might even make your script (infinitesimally) slower, whilst changing nothing."},"comment":{"url":"https://api.github.com/repos/PoshCode/PowerShellPracticeAndStyle/issues/comments/238930644","html_url":"https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/67#issuecomment-238930644","issue_url":"https://api.github.com/repos/PoshCode/PowerShellPracticeAndStyle/issues/67","id":238930644,"user":{"login":"TobiasPSP","id":20953725,"avatar_url":"https://avatars.githubusercontent.com/u/20953725?v=3","gravatar_id":"","url":"https://api.github.com/users/TobiasPSP","html_url":"https://github.com/TobiasPSP","followers_url":"https://api.github.com/users/TobiasPSP/followers","following_url":"https://api.github.com/users/TobiasPSP/following{/other_user}","gists_url":"https://api.github.com/users/TobiasPSP/gists{/gist_id}","starred_url":"https://api.github.com/users/TobiasPSP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TobiasPSP/subscriptions","organizations_url":"https://api.github.com/users/TobiasPSP/orgs","repos_url":"https://api.github.com/users/TobiasPSP/repos","events_url":"https://api.github.com/users/TobiasPSP/events{/privacy}","received_events_url":"https://api.github.com/users/TobiasPSP/received_events","type":"User","site_admin":false},"created_at":"2016-08-10T16:54:41Z","updated_at":"2016-08-10T16:54:41Z","body":"So why strongly type a variable? If you always write perfect code, you can get around a lot of things that otherwise can protect you."}}
{"actor":{"display_login":"TobiasPSP"}}