Title: Suggestion: implement ternary conditionals · Issue #3239 · PowerShell/PowerShell · GitHub
Open Graph Title: Suggestion: implement ternary conditionals · Issue #3239 · PowerShell/PowerShell
X Title: Suggestion: implement ternary conditionals · Issue #3239 · PowerShell/PowerShell
Description: C-style ternary conditionals would be a handy addition to the language. For instance, instead of writing: if ((get-date).tostring("ss") % 2) { 'odd' } else { 'even' } one could write: (get-date).tostring("ss") % 2 ? 'odd' : 'even' It wou...
Open Graph Description: C-style ternary conditionals would be a handy addition to the language. For instance, instead of writing: if ((get-date).tostring("ss") % 2) { 'odd' } else { 'even' } one could write: (get-date).to...
X Description: C-style ternary conditionals would be a handy addition to the language. For instance, instead of writing: if ((get-date).tostring("ss") % 2) { 'odd' } else { 'even' } one ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3239
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Suggestion: implement ternary conditionals","articleBody":"C-style ternary conditionals would be a handy addition to the language.\r\n\r\nFor instance, instead of writing:\r\n\r\n```powershell\r\nif ((get-date).tostring(\"ss\") % 2) { 'odd' } else { 'even' }\r\n```\r\n\r\none could write:\r\n\r\n```powershell\r\n(get-date).tostring(\"ss\") % 2 ? 'odd' : 'even'\r\n```\r\n\r\nIt would also relieve a long-standing disappointment:\r\n\r\n\u003e At Microsoft, “to ship is to choose”. One of the things we were very disappointed in not being able to ship in V1.0 is a ternary operator.\r\n\r\nFrom a [PowerShell Team blog post](https://blogs.msdn.microsoft.com/powershell/2006/12/29/diy-ternary-operator/) dated 29 December 2006.\r\n\r\n---\r\n\r\nRelated: [implement null-coalescence and null-soaking and null-conditional assignments](https://github.com/PowerShell/PowerShell/issues/3240)","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-03-02T20:06:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":52},"url":"https://github.com/3239/PowerShell/issues/3239"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:12f090b7-e3f2-3378-1f73-3a106e382c7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7B2:1D3A47:BA8555:F5A520:6A5B051E |
| html-safe-nonce | 9125b864b30ef906f2569d603a3126522d0bcc20b563db4c19696255dc088037 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0IyOjFEM0E0NzpCQTg1NTU6RjVBNTIwOjZBNUIwNTFFIiwidmlzaXRvcl9pZCI6IjU4NjczMjY0NDM3MDYwNTgwMTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 83192394410dcff5a7d93f8d0e19e2d942b769a2cdc7b330baebea095316e4e6 |
| hovercard-subject-tag | issue:211502211 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/3239/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2aaa7a654d7f2f78a1d9a5cfbd5b9cd301354e70ded230ececeea0da2f7a4a70/PowerShell/PowerShell/issues/3239 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2aaa7a654d7f2f78a1d9a5cfbd5b9cd301354e70ded230ececeea0da2f7a4a70/PowerShell/PowerShell/issues/3239 |
| og:image:alt | C-style ternary conditionals would be a handy addition to the language. For instance, instead of writing: if ((get-date).tostring("ss") % 2) { 'odd' } else { 'even' } one could write: (get-date).to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width