I'm a complete beginner at programming, but I have been a blockchain enthusiast for quite some time, so a lot of the concepts and ideas are familiar to me already, except these more technical ones. Bare with me if I say nonsense.
Right now i'm doing a tutorial to learn how to make a blockchain game, with Solidity, mostly for fun and learning. There's a part that got me thinking and I still can't grasp it even after checking other threads.
The tutorial:
"In Solidity, functions are public by default. This means anyone (or any other contract) can call your contract's function and execute its code.
uint[] numbers; function _addToArray(uint _number) private { numbers.push(_number); }
This means only other functions within our contract will be able to call this function and add to the numbers array."
So inside a program, I have various functions right? some are private, some are public. What my question is, in a broader sense, how exactly are these functions called by other smart contracts?? And what kind of stuff could they do?
What I think it is (and I may be totally wrong), is that I could make a Smart Contract X with public functions. Then someone else makes Smart Contract Y, and in that smart contract, they call out some of the functions I made in X. So someone can make a Smart Contract based on many other Smart Contracts essentially. And because they are in the blockchain, forever and immutable, the new Smart Contract is guaranteed to run every time successfully since its base is never going to be altered or corrupted.
I have no idea. Could someone give me examples of how this "calling" could work. Please, analogy or practical examples would make me understand much better!