I have very a basic question. I have a MethodB returning Integer. I have a MethodA where I want to pass the value retrieved from MethodB.
Is it a right way (the coding style, not the syntax) to pass MethodB to MethodA as mentioned below?
MethodA(MethodB());
You are not passing the method ‘MethodB’ but the value that it returns.
In fact, your code is equivalent to:
It’s perfectly ok to do it, as long as your code remains readable.