-- Append string to file function file_utils.append_file(filename, content) local f, err = io.open(filename, "a") if not f then return false, err end f:write(content) f:close() return true end

file_utils.write_file("test.txt", "Lua rocks!") print(file_utils.read_file("test.txt"))

-- Check if a value exists in a table (linear search) function table_utils.contains(tbl, value) for _, v in pairs(tbl) do if v == value then return true end end return false end

-- Read entire file as string (returns nil + error on failure) function file_utils.read_file(filename) local f, err = io.open(filename, "r") if not f then return nil, err end local content = f:read("*all") f:close() return content end

Back to list

Related Posts

2 thoughts on ““6 Best Free CVC Words Worksheets Every Parent and Teacher Needs”

  1. I’ve been surfing online more than 4hours today, yet Inever found any interesting
    artucle like yours. It’s pretty worth enough for me. Personally, iff all web owners andd bloggers made good content as you did, the iternet will be much more useful than ever before. https://www.waste-ndc.pro/community/profile/tressa79906983/

Leave a Reply

Your email address will not be published. Required fields are marked *