跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

lookup Function ​

lookup retrieves the value of a single element from a map, given its key. If the given key does not exist, a the given default value is returned instead.

hcl
lookup(map, key, default)

INFO

For historical reasons, the default parameter is actually optional. However, omitting default is deprecated since v0.7 because that would then be equivalent to the native index syntax, map[key].

Examples ​

shellsession
> lookup({a="ay", b="bee"}, "a", "what?")
ay
> lookup({a="ay", b="bee"}, "c", "what?")
what?
  • element retrieves a value from a list given its index.

基于 MPL-2.0 许可证发布。