Documentation lists multiple versions of the same function

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
kaikalii
Prole
Posts: 1
Joined: Mon Sep 28, 2020 11:18 am

Documentation lists multiple versions of the same function

Post 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?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Documentation lists multiple versions of the same function

Post 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
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Documentation lists multiple versions of the same function

Post by zorg »

Either that, or the function was changed across versions and you set the version selector to show all versions.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 5 guests