lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Dec 14, 2012 at 8:19 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> merge(...): returns a new table containing all the pairs from all the
>    tables given as arguments. In particular, if there is only one argument,
>    returns a shallow copy. In case of duplicate keys, later values
>    replace earlier ones. Nil arguments are treated as empty tables.

Penlight's tablex.merge is a little different:

http://stevedonovan.github.com/Penlight/api/modules/pl.tablex.html#merge

    merge({alice=23,fred=34},{bob=25,fred=34}) is {fred=34}

    merge({alice=23,fred=34},{bob=25,fred=34},true) is {bob=25,fred=34,alice=23}

since it distinguishes between 'intersection' (default) and 'union'

I'd say the default is exactly the wrong way around, personally...

steve d.