Hacker News new | ask | show | jobs
by titovodka 1737 days ago
I might not be aware of best practices.

What are the benefits of having a multiple return type function?

I just assume that one can use an object if this is needed throughout the whole code..

Or maybe create an arraylist if possible and return that?

1 comments

Using the object(/class) as you say is the probably "the Java way" to do this, given their historical "everything is an object" stance (which has been eroded a bit, though, with some of the functional support). But it sure is nice to do a multi-returns, here and there, without having to create another class. A class which required you to write boilerplate (getters/setters). Maybe records are some sort of compromise. Probably a non-compromise for people who like the multi-returns.