I was late to the PR review before it got merged. I find the anonymous function a bit confusing. I wonder how new users will think of it.
Will new users get confused about what to do with the scores
argument? Will they think that maybe they can use it in the HighScores methods as some kind of closure?
I think we should add at least some kind of comment that the scores argument needs to be added to the high_scores object … somehow. Something like
return function(scores)
local high_scores = {}
-- TODO: store the scores in the high_scores object ...
setmetatable(high_scores, { __index = HighScores })
return high_scores
end