lua-users home
lua-l archive

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


On Sun, Jul 4, 2021, 14:21 Egor Skriptunoff <egor.skriptunoff@gmail.com> wrote:
Problem #3
Hide a string of arbitrary length into an existing table without modifying its original content.
In other words, write functions hide(tab, str) and str=unhide(tab).
A user may assign non-nil values to existing keys of the table between hide() and unhide() invocations.

I may be misunderstanding the problem, but based on how I understand the constraints:

local secret_key={}
function hide(tab, str) tab[secret_key]=str end
function unhide(tab) return tab[secret_key] end

This does not "modify its original content".