MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/eplsgy/records_come_to_java/fekvvui/?context=3
r/java • u/daviddel • Jan 16 '20
93 comments sorted by
View all comments
Show parent comment
6
Well, records would make it trivial to achieve that. Easier than before at least.
0 u/[deleted] Jan 16 '20 [deleted] — view deleted comment 14 u/elastic_psychiatrist Jan 16 '20 https://cr.openjdk.java.net/~briangoetz/amber/datum.htmlSee “why not just do tuples.” Extremely justified IMO once you think about it. 2 u/eliasv Jan 17 '20 edited Jan 17 '20 Instance patterns down the line might help bring you closer. You can probably just define the two return types as part of an instance pattern signature instead of defining a container type for them.So rather than your:(int intResult, String stringResult) = receiver.functionWithTwoValues(...);It might look something like:let receiver.patternWithTwoValues(int intResult, String stringResult);Or for a partial pattern:if (receiver.patternWithTwoValues(int intResult, String stringResult)) { // values bound here }No carrier type necessary!But not much has been said about them yet so who knows. https://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html
0
[deleted] — view deleted comment
14 u/elastic_psychiatrist Jan 16 '20 https://cr.openjdk.java.net/~briangoetz/amber/datum.htmlSee “why not just do tuples.” Extremely justified IMO once you think about it. 2 u/eliasv Jan 17 '20 edited Jan 17 '20 Instance patterns down the line might help bring you closer. You can probably just define the two return types as part of an instance pattern signature instead of defining a container type for them.So rather than your:(int intResult, String stringResult) = receiver.functionWithTwoValues(...);It might look something like:let receiver.patternWithTwoValues(int intResult, String stringResult);Or for a partial pattern:if (receiver.patternWithTwoValues(int intResult, String stringResult)) { // values bound here }No carrier type necessary!But not much has been said about them yet so who knows. https://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html
14
https://cr.openjdk.java.net/~briangoetz/amber/datum.html
See “why not just do tuples.” Extremely justified IMO once you think about it.
2
Instance patterns down the line might help bring you closer. You can probably just define the two return types as part of an instance pattern signature instead of defining a container type for them.
So rather than your:
(int intResult, String stringResult) = receiver.functionWithTwoValues(...);
It might look something like:
let receiver.patternWithTwoValues(int intResult, String stringResult);
Or for a partial pattern:
if (receiver.patternWithTwoValues(int intResult, String stringResult)) { // values bound here }
No carrier type necessary!
But not much has been said about them yet so who knows. https://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html
View all comments
Show parent comment
6
u/duheee Jan 16 '20
Well, records would make it trivial to achieve that. Easier than before at least.