-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch support #448
Comments
Note that in Bicep the equivalent should work:
We should also soon be able to go even further and use the type system to validate that e.g. we've got a mismatch between param declaration and usage:
|
@anthony-c-martin Yes it will work but the point was to have easier to use syntax by novice people who may come from different languages background. |
This is where I have issues the "json-like" syntax. When you look at the var myVar, in bicep you have the "no comma" object
However, if we switch this to a parameter, the parameter becomes an object and passing this requires real JSON: Bicep
PowerShell$json = '{"third":"name3","first":"name1","second":"name2"}'
$hash = $json | ConvertFrom-Json
$param = @{
myParam = $Hash
}
New-AzResourceGroupDeployment -Name testDeploy -ResourceGroupName BicepTesting `
-TemplateFile .\switchTest2.json -TemplateParameterObject $param CLIaz deployment group create --resource-group bicepTesting \
--template-file switchTest2.json \
--parameters myParam='{"third":"name3","first":"name1","second":"name2"}' I realize this is a parameter vs. template issue, but I feel it would be a much nicer development experience overall if objects and arrays supported pure JSON syntax. |
What is the bicep equivalent of |
There is no switch expression so there is no equivalent of a default on a switch. The only conditional logic on properties is the ternary operator: var trueThing = true
output isItTrue string = trueThing ? 'It is true' : 'If it is not, I will be emitted by default' In some sense, the third argument of the ternary operator is the closes that exists to |
I think that's the point of having a if-ifelse-else (#1171) or switch-like operator? |
Is your feature request related to a problem? Please describe.
Provide option for Switch support. In cases where we have more then two choices we need switch support. I do not think Ternary operator can do that. In ARM templates you can solve that in some ways like having variable objects like
and of course when you need to use it you do something like:
You could basically have switch function and simplify that approach in Bicep. Downside is that I do not see a way of default value or more advanced ways of working like in PowerShell.
The text was updated successfully, but these errors were encountered: