Four different Raycast functions?

Hi all. I’m reading and trying to make sense of the raycast documentation:

Like all other docs, it mentions the function name, parameters, returns and description.

And then it just goes straight on and lists another three entire sets of parameters, returns, and descriptions, without naming any new function.
I’m trying to gel this with what i generally know about object oriented programming, and it just feels wrong.

Like the first one takes origin, direction, distance, and layermask
But then the second function takes Origin, direction, distance, hitInfo, and layermask.

How is that possible ? how does it not just throw a compiler error because you passed it a RaycastHit when it was expecting a LayerMask?

Can someone please explain this like i’m a student?

This is a feature of c# (and many other coding languages). In short: You can define the same function with different parameters, and as long as they’re different, the compiler will know which one you mean, based on the arguments you pass it. For example:

void poly(int a)
{
    print("I got an int.");
}

void poly(double a)
{
    print("I got a floating point.");
}

<...>

poly(1); //result: "I got an int";
poly(1.525); //result: "I got a floating point."

And it will let you know, when it can’t find a suitable override.

poly("hi"); //results in an error