Issue #16286 has been reported by Andrew McNaughton.
----------------------------------------
Feature #16286: add || operator
https://projects.puppetlabs.com/issues/16286
Author: Andrew McNaughton
Status: Unreviewed
Priority: Normal
Assignee:
Category:
Target version:
Affected Puppet version:
Keywords:
Branch:
There's a pattern in common usage that goes like this:
class foo ( $val = undef ) {
$real_val = $val ? {
undef => $name,
default => $val,
}
resource bar {baz: val => $realval}
}
It's an ugly hack. It would be a lot simpler like so:
class foo ( $val = undef ) {
$real_val = $val || $name
resource bar {baz: val => $realval}
}
Or, (where templates are not involved):
class foo ( $val = undef ) {
resource bar {baz: val => $val || $name}
}
The && and ||= operators common in other languages might also be useful at
times, and their meanings from other languages are well known and unambiguous.
However, || is the one I'm feeling the strongest need for.
The common need for $real_val as above grates a bit too. I imagine it would be
a more complex change to implement, but what if the values passed as parameters
could be overridden once in the same way as ones from an inherited class?
Presumably the externally provided parameters would get their own namespace.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.