diff --git a/05_hash_tables/lua/01_price_of_groceries.lua b/05_hash_tables/lua/01_price_of_groceries.lua new file mode 100644 index 0000000..d03aaa3 --- /dev/null +++ b/05_hash_tables/lua/01_price_of_groceries.lua @@ -0,0 +1,10 @@ +local book = {} +-- an apple costs 67 cents +book["apple"] = 0.67 +-- milk costs $1.49 +book["milk"] = 1.49 +book["avocado"] = 1.49 + +for key, value in pairs(book) do + print(key .. ": " .. value) +end \ No newline at end of file diff --git a/05_hash_tables/lua/02_check_voter.lua b/05_hash_tables/lua/02_check_voter.lua new file mode 100644 index 0000000..8a73cb7 --- /dev/null +++ b/05_hash_tables/lua/02_check_voter.lua @@ -0,0 +1,13 @@ +local voted = {} +function check_voter(name) + if voted[name] then + print("kick them out!") + else + voted[name] = true + print("let them vote!") + end +end + +check_voter("tom") +check_voter("mike") +check_voter("mike") \ No newline at end of file