# HG changeset patch # User Matthew Wild # Date 1591263552 -3600 # Node ID 5777968301e8bb21cfae9ba976ca8d864aa1d51f # Parent d15a4284fdf887014f01839694439283d5ef65a2 util.array: pluck: Support default value to avoid holes diff -r d15a4284fdf8 -r 5777968301e8 util/array.lua --- 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