fizzbuzz = { [0] = "Fizz Buzz", [3] = "Fizz", [5] = "Buzz", [6] = "Fizz", [9] = "Fizz", [10] = "Buzz", [12] = "Fizz", print = function(self, i) print(self[i % 15] or i) end } for i = 1, 15 do fizzbuzz:print(i) end
実行結果。
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 Fizz Buzz