lua-users home
lua-l archive

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


Hi all!

Sometimes I need to merge two tables, depending on task creating a new
one, or modifying one of that two.

  l = { one = 1; two = 2; three = 3; a = 1 }
  r = { four = 4; five = 5; six = 6; a = 2 }

  --> t1 == { one = 1; two = 2; three = 3; four = 4; five = 5; six = 6; a = 2 }
  t1 = get_merged(l, r)

  --> a == { one = 1; two = 2; three = 3; four = 4; five = 5; six = 6; a = 2 }
  merge_to(l, r) -- this changes left table

How to do it most effectively?

Thanks in advance,
Alexander.