-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
It's counterintuitive to initialize variables that will eventually hold a map or slice value with false or an empty string.
For example:
{{ $map := false }} // Looks like an error
{{ if .foo }}
{{ $map = .foo.configMap }}
{{ $map.baz }}
More intuitive:
{{ $map := nil }} // Looks correct
{{ if .foo }}
{{ $map = .foo.configMap }}
{{ $map.baz }}
A nil literal would also enable testing for zero values exactly instead of falsey values more broadly:
{{ if $foo }} // If any truthy value
{{ if ne $foo nil }} // If not nil
I couldn't find a previous proposal for this, open or closed.
seankhliao