Last active
December 12, 2021 05:21
-
-
Save bbarker/4c8b38c9377e22b404ec025183ebc349 to your computer and use it in GitHub Desktop.
This example has the same result in Scala 2, though in Java there is one difference that relates to the fact that Java (unlike Scala) does not support declaration-site variance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayList<JavaBean<Object>> beanList1 = new ArrayList(Arrays.asList(bean1, bean2, bean3)); | |
public <A> void polySetAllBeansToFirst(List<JavaBean<A>> beanList) { | |
beanList.forEach((bean) -> bean.setTheA(beanList.get(0).getTheA())); | |
} | |
polySetAllBeansToFirst(beanList1); | |
// ^ We can't do this in Scala, because we can't even construct beanList1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment