sree973
11/06/2017, 3:03 AMalex.krupa
11/06/2017, 6:45 AMsree973
11/06/2017, 7:54 PMkatz
11/14/2017, 10:58 AMobject : TypeToken<ApiResponse<<String>>() {}
- How about to extend typealias to expressions?
exp Foo<Gen1, ... GenX> = object : TypeToken<ApiResponse<<Gen1>>() {}
Foo<String,Float....>
exp Foo(param1,... paramX) = fun param1 (param2 : String) ....
Foo(a,b)
fun a(b)
Smth like c++ definesnrostov
11/14/2017, 11:05 AMinline fun <reified T> typeToken<T>() = object: TypeToken<T>()
katz
11/14/2017, 11:11 AMvoddan
11/16/2017, 10:44 AM@JvmStatic
and @JvmField
- references to companion objects pollute Java API and IDE code completion
I propose reinterpreting currently useless private companion object {...}
in a way that from Kotlin the companion object cannot be used and companion members can only be called on the class itself, and from Java all companion members are static methods and fields.
An example:
class A {
private companion object {
val bar = 239
fun foo() = "hello"
}
}
, Kotlin:
A.foo() // ok
A.bar // ok
A.Companion.foo() // Error
A.Companion.bar // Error
, Java:
A.foo(); // ok
A.bar; // ok
A.Companion // Error
What do you think? Has it been discussed before ?mikehearn
11/16/2017, 11:05 AMbeholder
11/16/2017, 6:02 PMkarelpeeters
11/16/2017, 6:07 PMsksk
11/17/2017, 9:31 AMvoid myMethod()
{
{
// i do something
}
{
// i do another thing
}
}
ilya.gorbunov
11/17/2017, 9:40 AMrun
sksk
11/17/2017, 9:52 AMarekolek
11/19/2017, 2:10 PMpublic interface SamJava {
void many(@NonNull String a,
@NonNull AccidentalSamInterface b,
@NonNull AccidentalSamInterface c,
@NonNull AccidentalSamInterface d,
@NonNull SamInterface e);
interface SamInterface {
void doSomething();
}
interface AccidentalSamInterface {
String getSomeString();
}
}
arekolek
11/19/2017, 2:13 PMfun testSam(test: SamJava, x: AccidentalSamInterface) {
test.many("", x, x, x, SamInterface { })
}
The variant with all lambdas doesn't make much sense here, we could use {x.someString}
for middle parameters, but that would generate intermediate objects for no reason.arekolek
11/19/2017, 2:14 PMfun SamJava.many(
a: String,
b: AccidentalSamInterface,
c: AccidentalSamInterface,
d: AccidentalSamInterface,
e: () -> Unit
) {
many(a, b, c, d, SamInterface(e))
}
arekolek
11/19/2017, 2:15 PMfun testSam(test: SamJava, x: AccidentalSamInterface) {
test.many("", x, x, x) { }
}
arekolek
11/19/2017, 2:17 PMLiveData<T>.observe(LifecycleOwner owner, Observer<T> observer)
that has a SAM type as the last argument that is intended to be passed as a lambda, but has other SAM typed parameters that are not intended to be passed as lambdas.artem_zin
11/23/2017, 12:43 AMtrevjones
11/28/2017, 10:15 PMtypealias WhatUp = Workers.State
data class Workers(val whatItIs: State) {
sealed class State {
object Working: State()
object WastingTime: State()
}
}
fun askWhatup(group: Workers) {
when(group.whatItIs) {
is Workers.State.Working -> println("busy yo.")
is WhatUp.WastingTime -> println("we good.")
// error: unresolved reference: WastingTime
// is WhatUp.WastingTime -> println("we good.")
// ^
}
}
spand
11/29/2017, 9:36 AMgregd
11/29/2017, 9:55 AMinterface SimpleFoo<T> : Foo<T, Unit, Unit>
Introducing a new type just for this is cumbersome. And inconvenient for the users, because they have to know about this type.gregd
11/29/2017, 9:56 AMAsyncTask
could be declared as:
abstract class AsyncTask<Params, Result, Progress = Void>
Ruckus
11/29/2017, 4:49 PMtypealias SimpleFoo<T> = Foo<T, Unit, Unit>
elect
11/29/2017, 4:57 PMelect
11/29/2017, 5:17 PMfun addConstraint(constraint: TypedConstraint) = addConstraint(constraint, disableCollisionsBetweenLinkedBodies = false)
override fun addConstraint(constraint: TypedConstraint, disableCollisionsBetweenLinkedBodies: Boolean) {
kirillrakhman
11/30/2017, 8:03 AMelect
11/30/2017, 8:10 AMkevinmost
11/30/2017, 4:06 PMkevinmost
11/30/2017, 4:07 PMstr.replace('"'.toString(), '\' + '"')
. Either way, both quotes and backslashes aren't exactly the common scenario since they're reserved for both starting/ending a string, and for escaping characters within a string, so I wouldn't want a language feature designed specifically just to make them easier to look at