Page 1 of 1

Documentation lists multiple versions of the same function

Posted: Mon Sep 28, 2020 11:22 am
by kaikalii
I am very confused about some of the documentation which lists more that one version of a function. To my knowledge, Lua functions can be variadic, but there is only one version of each.

For example, the documentation for love.graphics.newFont (https://love2d.org/wiki/love.graphics.newFont), lists 4 different versions. How do I determine which one my code will use?

Re: Documentation lists multiple versions of the same function

Posted: Mon Sep 28, 2020 12:14 pm
by grump
There is only one function, but what that function does depends on the number and the types of the call arguments.

Code: Select all

love.graphics.newFont('myfont.ttf')               -- create font with default size and options
love.graphics.newFont('myfont.ttf', 32)           -- create font at size 32 with default options
love.graphics.newFont('myfont.fnt', 'myfont.png') -- create ImageFont from these files
-- etc.
See also: https://en.wikipedia.org/wiki/Function_overloading

Re: Documentation lists multiple versions of the same function

Posted: Mon Sep 28, 2020 1:08 pm
by zorg
Either that, or the function was changed across versions and you set the version selector to show all versions.