Software /
code /
prosody
Changeset
10895:5777968301e8
util.array: pluck: Support default value to avoid holes
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 04 Jun 2020 10:39:12 +0100 |
parents | 10894:d15a4284fdf8 |
children | 10896:c7a0eab27165 |
files | util/array.lua |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/util/array.lua Wed Jun 03 22:58:29 2020 +0100 +++ b/util/array.lua Thu Jun 04 10:39:12 2020 +0100 @@ -134,9 +134,13 @@ end); end -function array_base.pluck(outa, ina, key) +function array_base.pluck(outa, ina, key, default) for i = 1, #ina do - outa[i] = ina[i][key]; + local v = ina[i][key]; + if v == nil then + v = default; + end + outa[i] = v; end return outa; end