diff options
-rw-r--r-- | util/array.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/util/array.lua b/util/array.lua index 32d2d6a5..6e5c8383 100644 --- a/util/array.lua +++ b/util/array.lua @@ -134,9 +134,13 @@ function array_base.unique(outa, ina) 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 |