benleggiero
03/11/2018, 3:16 PMhttps://i.imgur.com/0wvUraX.png▾
bod
03/11/2018, 4:10 PMbenleggiero
03/11/2018, 5:03 PMclass Foo<Bar>(
initial: Bar?
) {
private val internal: Any? = initial
fun baz(): Bar? {
val i = internal
return if (i is Bar) i
else null
}
}
Error: Cannot check for instance of erased type: Bar
diesieben07
03/11/2018, 5:44 PMfun <T> bind(type: Class<T>, instance: T)
fun <T> bind(type: Class<T>, factory: Function<T>)
Calling it like this fails with "Cannot choose among the following candidates without completing type inference":
bind(MyClass::class.java, { p: String -> MyClass(p) })
Why is this? Using a reference instead of a lambda (bind(MyClass::class.java, ::MyClass)
) works fine. What am I missing here?liz3
03/11/2018, 11:32 PMfun main(args: Array<String>) {
System.setOut(SprummlbotOutStream())
System.out.println("Test System.out.println()")
println("Test println")
}
Thats the output:
[12.3.2018 00:26:40 | INFO] Test System.out.println()
Test println
Process finished with exit code 0
SprummlbotOutStream
public class SprummlbotOutStream extends PrintStream {
public SprummlbotOutStream() {
super(System.out);
}
@Override
public void println(String msg) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("d.M.Y HH:mm:ss");
if (!msg.startsWith("["))
msg = " " + msg;
super.println("[" + sdf.format(cal.getTime()) + " | INFO]" + msg);
}
}
My question: why does println use the old stream?
Kotlin pl: 1.2.30
JDK: 1.8.0_162gladsonreisgtr
03/12/2018, 3:56 AMdeviant
03/12/2018, 9:00 AMpython
from time to time. and sometimes trying to bring python syntax into kotlin. probably i must be shot for such things anyway 🙂diesieben07
03/12/2018, 11:19 AMval (a, b, c) = line.split("\t") + listOf(null, null, null)
Kulwinder Singh
03/12/2018, 12:11 PMConcurrentModificationException
Kulwinder Singh
03/12/2018, 12:15 PMMusicStore
object to make it safe from errors/race conditions ? do I need to change type of lists
tschuchort
03/12/2018, 1:30 PMEntry
objects stay valid when the backing map is modified? I want to hold on to the Entry
object so I don't have to access the map every time when all I need is that one entryGerard de Leeuw
03/12/2018, 6:26 PMlogzet
03/12/2018, 9:10 PMRuckus
03/12/2018, 10:32 PMdiesieben07
03/12/2018, 10:35 PMClass<T>
into the exception.cedric
03/13/2018, 5:45 AMneil.armstrong
03/13/2018, 11:36 AMlistOf
will create an immutable list
/**
* Returns an immutable list containing only the specified object [element].
* The returned list is serializable.
* @sample samples.collections.Collections.Lists.singletonReadOnlyList
*/
@JvmVersion
public fun <T> listOf(element: T): List<T> = java.util.Collections.singletonList(element)
Andreas Sinz
03/13/2018, 11:45 AMclass MyImmutableList<T>(private val list: List<T>): List<T> by list
then the user won't be able to cast your list into a MutableList
and therefore won't be able to edit itspand
03/13/2018, 12:01 PMKonstantin Petrukhnov
03/13/2018, 2:56 PManderson.faro
03/14/2018, 1:10 AMpniederw
03/14/2018, 4:05 AMelect
03/14/2018, 10:28 AM@JvmName("dotFloat")
methods in `interface`s?remen
03/14/2018, 3:24 PMdeviant
03/14/2018, 3:32 PMcollection literals
feature? can't find it on the trackerCzar
03/14/2018, 5:33 PMdata class Person(val name: String, val age: Int) {
init {
Person::class.memberProperties
.find { it.name == "name" }
?.javaField
?.let {
it.isAccessible = true
it[this] = "${it[this] as String}suffix"
it.isAccessible = false
}
}
}
Mahmood Ali
03/14/2018, 7:11 PMShawn
03/14/2018, 7:46 PMjameskleeh
03/14/2018, 7:53 PMShenny
03/14/2018, 10:27 PMShenny
03/14/2018, 10:27 PMelizarov
03/15/2018, 5:10 AM