Can we have different return types for a function if it has more than one data type passed to it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Can we have different return types for a function if it has more than one data type passed to it?

If we compare an integer and a floating point number, can we have different return types matching that of the variable?

12th Jun 2020, 11:48 AM
Prabhanshu Chaturvedi
6 Answers
0
Prabhanshu Chaturvedi Same thing goes for Java. Example of languages that support multiple return values are Python, Go and Swift
12th Jun 2020, 12:06 PM
Ore
Ore - avatar
+ 4
C++?
12th Jun 2020, 11:51 AM
Prabhanshu Chaturvedi
+ 4
Ok. Thank you. Is it possible in Java?
12th Jun 2020, 12:02 PM
Prabhanshu Chaturvedi
+ 4
Oh, I see. Thank you again.
12th Jun 2020, 12:08 PM
Prabhanshu Chaturvedi
0
It is possible in some languages and impossible in others. So please specify which language?
12th Jun 2020, 11:50 AM
Ore
Ore - avatar
0
Prabhanshu Chaturvedi C++ does not support multiple return values but you can place the values in a tuple and return the tuple
12th Jun 2020, 11:56 AM
Ore
Ore - avatar