jeggy
10/08/2019, 4:36 PMtypeOf<>()
function was released as an experimental function in 1.3.40
. Is it possible to follow the progress of this or know how long before it will be marked as not experimental?Justin
10/08/2019, 7:45 PMzip
, but instead of returning pairs based on index, it returns pairs based on a predicate.
For example:
data class A(val id: String)
data class B(val id: String)
val listA: List<A> = listOf(A(“3”), A(“8”))
val listB: List<B> = listOf(B(“8”), B(“2”), B(“4”))
val pairs: List<Pair<A, B>> = listA.someTransformation(listB) { it.id == id }
// ‘pairs’ would contain:
// listOf((A("8"), B("8"))
Would love to know if there’s a best practice around this type of operation?groostav
10/08/2019, 7:48 PM...error: overload resolution ambiguity:
[javac] @InlineOnly public inline fun Double.isInfinite(): Boolean defined in kotlin
[javac] @InlineOnly public inline fun Double.isInfinite(): Boolean defined in kotlin
when I build from ant, but my classpath looks OK. Is there any way I can get kotlinc
to tell me where its getting these two functions from?benny.huo
10/08/2019, 10:54 PMw_bianrytree
10/09/2019, 9:23 AMclass A{
val b:Int = 0
val a:Int
init {
a = 2
}
}
Is there any order of a/b’s initialization? a first?w_bianrytree
10/09/2019, 9:27 AMclass MyView:View{
private val myChildView:View = findViewById(R.id.my_view_id)
init{
View.inflate(R.layout.my_layout,this)
}
}
There is a chance that myChildView is null because inflation is executed after findViewById.Luigi Scarminio
10/09/2019, 11:25 AMStephan Schroeder
10/09/2019, 2:48 PMlastEndTokenIndex
is -1
😐 If I use lastIndexOf
without fromIndex
than the result is the expected 40. But 40 is bigger than 0, so this fromIndex shouldn’t interfere with the result, should it??
fun main() {
val sb = StringBuilder("<products><product>2</product><product>4</product></products>")
val endToken = "</product>"
val fromIndex = 0
val lastEndTokenIndex = sb.lastIndexOf(endToken, fromIndex)
println("lastEndTokenIndex: $lastEndTokenIndex")
}
Kotlin Playground: https://pl.kotl.in/SlHzdIq1jraj
10/09/2019, 5:11 PMcom/sun/tools/doclets/formats/html/HtmlDoclet* Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
neworldlt
10/09/2019, 8:09 PMkotlinx.cli
looks abandoned. Can I expect this tool will be well maintained?Robert
10/09/2019, 8:30 PMvar
or val
in an interface, do I always have to use override
to "implement" it? I tried using abstract
in the interface
, but that's no helpdigitalsanctum
10/09/2019, 9:22 PMursus
10/09/2019, 9:29 PMclass Bar : Foo<Quax>()
abstract class Foo<T>
internal class Quax
error is public subclass exposes internal supertype argument
and this java works
public class Rah extends Meh<Ohe> {
}
class Ohe {
}
public abstract class Meh<T> {
}
When internal is looser modifier than package privateMatt Thiffault
10/09/2019, 10:32 PMstandinga
10/09/2019, 10:40 PMenum ThumbnailsSliderAction {
case scrub(time: CMTime, event: ThumbnailsSliderEvent)
case zoom(level: Int)
}
Matt Thiffault
10/10/2019, 12:45 AMjbnizet
10/10/2019, 6:37 AMfor (date in d1..d2)
where d1 and d2 are instances of java.time.LocalDate. I can do that by defining an extension function operator fun ClosedRange<LocalDate>.iterator()
. But is there a way to easily have that extension function imported in IntelliJ? Except for manually typing the import statement import my.package.iterator
at the top of the file, I haven’t found a way, which makes it quite unintuitive to use such a for loop. Is there a better solution that I’m missing?yawkat
10/10/2019, 9:58 AMozzmhmt
10/10/2019, 4:59 PMraj
10/10/2019, 6:39 PMSylvain Patenaude
10/10/2019, 8:55 PMamadeu01
10/11/2019, 1:09 AMMani
10/11/2019, 9:27 AMjbnizet
10/11/2019, 10:28 AMclass Dog {
var frightenedCats = 0
private set
fun frightenCat() {
frightenedCats++
}
}
Here’s the output (I just omitted the constructor) when decompiling the bytecode with `javap -p -c`:
private int frightenedCats;
public final int getFrightenedCats();
Code:
0: aload_0
1: getfield #10 // Field frightenedCats:I
4: ireturn
public final void frightenCat();
Code:
0: aload_0
1: dup
2: getfield #10 // Field frightenedCats:I
5: dup
6: istore_1
7: iconst_1
8: iadd
9: putfield #10 // Field frightenedCats:I
12: return
Note: I’m absolutely fine with that optimization. Just curious about it.thiagoretondar
10/11/2019, 2:43 PMMani
10/11/2019, 7:38 PMEllen Spertus
10/11/2019, 8:05 PMoverride fun onReject(token: String) {
if (savedConnectionState is ConnectionState.Authenticating) {
// do something
} else {
// complain
}
}
override fun onSend(message: String) {
if (savedConnectionState is ConnectionState.ReadyToSend) {
// do something
} else {
// complain
}
}
Is there a way to create a check()
method that takes a type (e.g., ConnectionState.Authenticating
) as an argument and tests whether the instance variable savedConnectionState
is that type?Ben Madore
10/11/2019, 8:31 PMfun <T> T?.whenNull(block: T?.() -> Unit): T? {
if (this == null) {
block()
}
return this
}
to be used like:
return getFoo().whenNull {
<http://log.info|log.info> {"can't find a foo"}
}
Luis Munoz
10/11/2019, 8:48 PMJason
10/12/2019, 12:35 AMItems
in your code:
fun main() {
val i = Items // <-- properties created here
println("a")
println(i.x)
// etc
}
Jason
10/12/2019, 12:35 AMItems
in your code:
fun main() {
val i = Items // <-- properties created here
println("a")
println(i.x)
// etc
}
Hamza
10/12/2019, 12:36 AMJason
10/12/2019, 12:37 AMHamza
10/12/2019, 12:37 AM