You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many languages offer syntactic sugar for defining default values in form of a null coalescing operator. The most common one seems to be ??. go-cty offers the coalesce() function for that purpose.
The function works, but with a little sugar everything is sweeter :)
Obviously, "falsish" values, such as 0 or the empty string, should not be considered null. 0 ?? 1 should evaluate to 0.
This is a feature proposal for hcl2. As ?? is a parse error at the moment, it should be possible to add the operator without breaking existing configurations.
The text was updated successfully, but these errors were encountered:
Many languages offer syntactic sugar for defining default values in form of a null coalescing operator. The most common one seems to be
??
.go-cty
offers thecoalesce()
function for that purpose.The function works, but with a little sugar everything is sweeter :)
HCL Template
(In reality, instead of
null
we would use an expression that could actually yield a non-null result.)Expected behavior
attribute1
should be assigneddefault
attribute2
should be assignedHello world
This is the same behaviour as of cty's
coalesce()
function:Obviously, "falsish" values, such as
0
or the empty string, should not be considered null.0 ?? 1
should evaluate to0
.This is a feature proposal for hcl2. As
??
is a parse error at the moment, it should be possible to add the operator without breaking existing configurations.The text was updated successfully, but these errors were encountered: