Miguel
12/24/2018, 4:14 PMMiguel
12/24/2018, 4:14 PMShawn
12/24/2018, 4:15 PMShawn
12/24/2018, 4:15 PMList<Any>Shawn
12/24/2018, 4:16 PMMiguel
12/24/2018, 4:17 PMval x: Date = lol("13/02/2018", Date::class.java) 🤔Shawn
12/24/2018, 4:18 PMlol() returns a different type based on the class you pass to it, you can still use genericsShawn
12/24/2018, 4:19 PMfun <T> lol(): T, you’d get a Date out of it by calling like this: lol<Date>()Shawn
12/24/2018, 4:20 PMClass<T> from it, use reifiedShawn
12/24/2018, 4:20 PMinline fun <reified T> lol()Miguel
12/24/2018, 4:21 PMShawn
12/24/2018, 4:25 PMinline, but the better question at this point really is what are you trying to do?Miguel
12/24/2018, 4:33 PM(2, 2) -> Int and (27/03/2017, 28/03/2017) -> LocalDate.
Ideally I would want a function fun <T> fromString(elementsString: String, classValue: Class<T>): List<T> that receives the string representation and returns the list of elements, which can be a list of 2 Ints or a list of 2 LocalDates.Miguel
12/24/2018, 4:35 PMfromString function to call the “parseInt” function and returning that, and only calling the “parseDate” if the other one was not well succeeded.Miguel
12/24/2018, 4:35 PMShawn
12/24/2018, 4:38 PMMiguel
12/24/2018, 4:41 PMval x: List<Int> fromString("[2,2]", Int::class.java)Miguel
12/24/2018, 4:43 PMfromString and I would like to delegate the responsibility of parsing to the wanted type to some other function.Shawn
12/24/2018, 5:00 PMShawn
12/24/2018, 5:03 PMMiguel
12/24/2018, 5:13 PMShawn
12/24/2018, 5:14 PMPavlo Liapota
12/25/2018, 10:13 AMMiguel
12/25/2018, 11:00 AM