/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/lua/lua-515-101-008/main.lua
29 строк
654 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
local function create_bank_account(initial_balance) local balance = initial_balance or 0 return { deposit = function(amount) if amount > 0 then balance = balance + amount end end, withdraw = function(amount) if amount > 0 and balance >= amount then balance = balance - amount return true end return false end, get_balance = function() return balance end } end local account = create_bank_account(100) account.deposit(50) account.withdraw(30) print(account.get_balance()) -- 120 -- поле `balance` недоступно напрямую извне