Created
December 12, 2021 04:57
-
-
Save bbarker/12328e73399a490a19fe1f46a7eff8d8 to your computer and use it in GitHub Desktop.
try to set values. Let's try making such a function
This file contains hidden or 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
def polySetAllBeansTo[A](beanList: List[ScalaBean[A]], initBean: ScalaBean[A]): Unit = | |
beanList.foreach{bean => | |
bean.setTheA(initBean.getTheA) | |
} | |
polySetAllBeansTo(beanList3, bean1) | |
// everything is now set to bean1's value | |
println(beanList2.map(_.getTheA)) | |
polySetAllBeansTo(beanList2, bean1) | |
// ❌ Found: (Playground.beanList2 : List[Playground.ScalaBean[?]]) | |
// Required: List[Playground.ScalaBean[Int]] | |
println(beanList2.map(_.getTheA)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment