I have a function, we’ll call it funcA that returns an object. I want to pass that object to funcB. Can I do this?
funcB(funcA());
so that funcA() is called first and the results are passed to funcB()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If it helps, Yisroel, you can think of the object returned “replaces” the function in-place. So, after funcA() is executed, it is “replaced” by the returned value and passed into funcB().
Generally, though, you wouldn’t want to do nesting functions like this for more than 3 levels. If it starts to become unreadable, store the object into a variable and passing this variable into the next function can make your code much more readable.
So the answer is yes, as everyone else pointed out.