adam-mcneilly
01/17/2018, 2:55 AMAyden
01/17/2018, 5:29 AMval
is read only right?Ayden
01/17/2018, 6:14 AMgildor
01/17/2018, 9:26 AMsabag.ronen
01/17/2018, 12:41 PMjw
01/17/2018, 3:26 PMfalse
Carl Hickman
01/17/2018, 7:59 PMjhonsef
01/17/2018, 8:02 PMClaudiuB
01/17/2018, 8:37 PMas?
or as
doesn't seem to work when using them with generic T: KClass<out Any>
. For example someClass as T
will return someClass
, even when T
is not `someClass`'s ancestor. if anyone could put an eye on the code in the comment to this, that would be great! Currently, in trying to achieve instanceof
-like behavior, my method returns true
for Nothing::class instanceof Number::class
and I wish I was joking 🤖 . I've been trying to figure this out for maybe 3 hours now?If I'm using generics properly, then as
and as?
are broken when used with generics?lex
01/18/2018, 3:56 AMVitaly
01/18/2018, 9:49 AMUnresolved reference: moduleName
Does anybody knows what can cause this problems?stefanem
01/18/2018, 12:52 PMfly2never
01/18/2018, 1:05 PMdiesieben07
01/18/2018, 2:29 PMplayer1.contains(it)
with it in player1
.cedric
01/18/2018, 6:39 PMUnsafe
hack thenjw
01/18/2018, 6:39 PMorangy
01/18/2018, 6:59 PMorangy
01/18/2018, 7:08 PMjkbbwr
01/18/2018, 7:36 PMTimur Valiev
01/19/2018, 3:43 AMTimur Valiev
01/19/2018, 5:08 AMjrtapsell
01/19/2018, 11:38 AMDecompile
button to change backtick names to make the java code valid?marstran
01/19/2018, 1:04 PMOuter::Inner
worked for me.Ansh
01/19/2018, 1:07 PMopen class A {
fun f() {
print("A")
}
}
interface B {
fun f() {
print("B")
}
}
class C: A(),B {
}
Now, this code doesn't compile because class 'C' extends class 'A' and implements interface 'B' and both of them have functions 'f'. So, as soon as I override 'f' function in class 'C', it throws a compilation error that 'f' cannot be overridden because 'f' is not open in class A. Now a similar set up in Java would have worked easily.
class A {
final public void f() {
System.out.println("A");
}
}
interface B {
default void f() {
System.out.println("B");
}
}
class C extends A implements B{
}
Wouldn't it be better if Kotlin also worked the same way as default method of Java interfaces work i.e pick up the default implementation only when no other implementation is available? And suppose if both class 'A' and interface 'B' are from a library, I won't be able to change the function 'f' to open. In that case it would be impossible for me to create the class 'C'. Does anybody here know what is the possible advantage of having this sort of implementation in Kotlin?diesieben07
01/19/2018, 2:32 PMIterable
means "has an iterator". That means every Iterable
can be used in the for
-in
loop, but something does not have to implement Iterable
to be used in the for
-in
loop. All that is required to do so is an operator fun iterator(): Iterator
.Shawn
01/19/2018, 2:54 PMJoe
01/19/2018, 3:16 PMdimsuz
01/19/2018, 3:18 PMinline + reified
in interfaces, but I still can achieve virtually the same thing with extension functions:
interface Store {
inline fun <reified T> getValue(key: String): T // impossible, no go
// so doing this
fun <T> getValue(key: String, clazz: Class<T>): T // good
}
class StoreImpl : Store {
override fun <T> getValue(key: String, clazz: Class<T>): T {
// code
}
}
inline fun <reified T> Store.getValue(key: String): T {
return this.getValue(key, T::class.java)
}
fun main(args: Array<String>) {
val i: Int = StoreImpl().getValue("hello")
}
diesieben07
01/19/2018, 4:22 PMList<@NotBlank String>
.
Is there a way to get the Kotlin compiler to properly generate type annotation metadata in a situation like this? Right now the @NotBlank
annotation is not visible with the Java reflection API, even with javaParameters
option set to true
.cy
01/19/2018, 4:37 PMcy
01/19/2018, 4:37 PMpoohbar
01/19/2018, 4:37 PMcy
01/19/2018, 4:38 PMpoohbar
01/19/2018, 4:39 PMcy
01/19/2018, 4:40 PMpoohbar
01/19/2018, 4:40 PMcy
01/19/2018, 4:41 PMCzar
01/19/2018, 4:41 PMpoohbar
01/19/2018, 4:42 PMcy
01/19/2018, 4:46 PMpoohbar
01/19/2018, 4:47 PMShawn
01/19/2018, 4:48 PMpoohbar
01/19/2018, 4:48 PMShawn
01/19/2018, 4:48 PMpoohbar
01/19/2018, 4:49 PMShawn
01/19/2018, 4:49 PMcy
01/19/2018, 4:49 PMShawn
01/19/2018, 4:50 PMpoohbar
01/19/2018, 4:50 PMShawn
01/19/2018, 4:51 PMpoohbar
01/19/2018, 4:51 PMShawn
01/19/2018, 4:52 PMcy
01/19/2018, 4:52 PMpoohbar
01/19/2018, 5:04 PMcy
01/19/2018, 5:05 PMpoohbar
01/19/2018, 5:08 PMcy
01/19/2018, 5:09 PMpoohbar
01/19/2018, 5:10 PMShawn
01/19/2018, 6:58 PM