Normally when you have multiple function names in a project, the last duplicate function name is used and the previous ones are ignored. Here’s a simple program that shows something different and unexpected to what I thought would happen. There are 3 draw functions, and each one gets executed. Apparently you can have multiple function names as long as they are nested. Once a function is executed, it replaces the previous function of the same name. The inside functions could be executed based on a variable name. I doubt if this has any use, but I found it interesting. I found this out when I formatted the program “Codea Timer” written by @AwesomeCodeaKid to make it easier for me to read. I guess you can learn something from a 9 year old. When you run this, the first draw function will run, then the second, then the third. I stop the third to prevent a lot of print statements.
function setup()
fill(255)
ct=0
end
function draw() -- draw 1
background(0)
print("running function draw 1")
function draw() -- draw 2
background(0)
print("running function draw 2")
function draw() -- draw3
background(0)
if ct<3 then
ct=ct+1
print("running function draw 3 count ",ct)
end
end
print("end of function draw 2")
end
print("end of function draw 1")
end