pablisco
06/15/2018, 9:40 AMSomething.kt
-> SomethingKt
) extend a particular type? 🤔jlleitschuh
06/15/2018, 3:55 PMval first by tasks.creating {
dependsOn(second)
}
val second by tasks.creating
Ayden
06/15/2018, 6:48 PMikt
06/16/2018, 6:40 AMkarelpeeters
06/16/2018, 12:38 PMashishkrishnan
06/16/2018, 5:28 PMAny
or Nothing
type mapped at runtime?karelpeeters
06/16/2018, 9:09 PM(Any) -> Unit
is a subtype of (String) -> Unit
, so you're supposed to be able the always replace the latter with the former if something is taking it.nwh
06/17/2018, 1:30 AMSlackbot
06/18/2018, 7:39 AMarekolek
06/18/2018, 1:41 PMval defaultHandler: Consumer<in Throwable>? = RxJavaPlugins.getErrorHandler()
checkNotNull(defaultHandler)
defaultHandler.accept(Throwable()) // only safe or non-null asserted calls are allowed on nullable receiver of type...
what's the point in this then:
public inline fun <T:Any> checkNotNull(value: T?, lazyMessage: () -> Any): T {
contract {
returns() implies (value != null)
}
egorand
06/18/2018, 2:07 PMmp
06/18/2018, 3:22 PMdata class Info(val id: Int val name: String, val phone: Long)
2) want to have data class InfoPayload(val id: Int? val name: String?, val phone: Long?)
maybe with some kind of annotation @payloadable
If no options - I want to ask about compilers plugins for kotlin: can any one share docs for implementation of kotlin-compiler-plugin?
tnxmuralimohan962
06/19/2018, 5:46 AMnikolay
06/19/2018, 2:37 PMnick.salerni
06/19/2018, 4:57 PMMelodeiro
06/19/2018, 6:40 PMLeoColman
06/19/2018, 8:02 PMaddAll(vararg)
? I didn't quite see a possible confusion thereJuan Guillermo Gomez - GDG Cali - GDE Firebase
06/19/2018, 11:20 PMeygraber
06/20/2018, 5:09 AMunless
-like operator:
sealed class Unless {
object unless : Unless() {
override val run: Boolean = false
}
object other : Unless() {
override val run: Boolean = true
}
abstract val run: Boolean
}
inline infix fun Unless.otherwise(block: () -> Unit) {
if(run) block()
}
inline fun unless(predicate: Boolean, block: () -> Unit): Unless =
if(!predicate) {
block(); Unless.unless
}
else {
Unless.other
}
o.semen
06/20/2018, 7:27 AMval b1: Byte = 2
val b3: Byte = 7
val b4 = b1 xor b3
and IDEA suggested import kotlin.experimental.xor
, but when I tried this:
val b1: Byte = 2
val b3: Byte = 7
val b4 = b1 shl b3
it does not have even anything to suggest.
It is sad as I’m implementing CRC calculation that requires quite a lot of binary operations on bytes an each time I have to cast my bytes….
I do realise that it is possible to write extension. But I’m still wandering why Byte is not treated the same way Int and Long is?iex
06/20/2018, 12:47 PMfun foo() = print("hello")
vs. fun foo() { print("hello") }
jgodort
06/20/2018, 12:56 PMchirag
06/20/2018, 1:27 PMdata class User(
val name: String? = null,
val address: String? = null,
val phone: String? = null
)
Suppose I have a data class like above
I am validating properties name, address, phone as not null
So if its not null how can i change its type to NotNullable because if i use this data class in anywhere else i always have to use !! or ? despite of its already validated for null check.
so that data class after validation looks like
data class User(
val name: String,
val address: String,
val phone: String
)
Anybody faced this problem ?Shawn
06/20/2018, 3:14 PMclass Foo(val bar, val baz) {
val doober = mutableMapOf<String, String>()
val qux: Set<String>
constructor(bar, baz, lad) : this(bar, baz) {
// do things to `doober` using `lad`
qux = doober.keys.toSet()
}
}
more specifically, qux
should be an empty set if the primary constructor is called, and a computed, read-only set if the secondary constructor is called, based on the results of evaluating the parameter unique to it. I tried a separate init
block declared after the secondary constructor to populate the set using the map, but it looks like the init block gets executed before the logic in the body of the secondary constructor.
for kicks, I also tried making qux
a constructor parameter, but you can’t call the primary constructor from the secondary one using values you compute in the latterchattered
06/20/2018, 4:30 PMsnowe
06/21/2018, 1:21 AMrrader
06/21/2018, 8:41 AMError:Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar is not compatible with this version of compiler
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:186)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:119)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:418)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:265)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:107)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:399)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:98)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:920)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:98)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:950)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:919)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:397)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:835)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.AbstractMethodError
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:184)
... 33 more
fabricio
06/21/2018, 4:17 PMfun findProfile(user: UserDocument, vararg fields: String) { ... }
I'd like to make the vararg parameter required, because if I call that method like userService.findProfile(user)
it doesn't complain.
Any idea?david-wg2
06/21/2018, 4:30 PMString?
, but it makes sense for java to return Optional<String>
?zvozin
06/21/2018, 8:23 PMzvozin
06/21/2018, 8:23 PMrobstoll
06/21/2018, 8:30 PM