Created
November 4, 2023 04:07
-
-
Save MaksimDmitriev/21d5be2789434fb871ddec7f07694f48 to your computer and use it in GitHub Desktop.
JvmSuppressWildcards sample
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
| object ListProcessor { | |
| fun processStrings(strings: List<Any>) { | |
| Printer.print(strings) | |
| } | |
| } |
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
| public class Printer { | |
| public static void print(List <Object> list) { | |
| for (Object o : list) { | |
| System.out.println(o); | |
| } | |
| } | |
| } |
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
| class SampleTest { | |
| @Test | |
| fun wildcard() { | |
| val strings = listOf("Hello", "World") | |
| ListProcessor.processStrings(strings) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment