ValV
10/22/2018, 10:34 PMSlava Kornienko
10/22/2018, 10:52 PMSlava Kornienko
10/22/2018, 11:01 PMpavel
10/23/2018, 6:12 PMjacob
10/24/2018, 5:05 AMSudhir Singh Khanger
10/25/2018, 5:51 PMCHEESE_DATA.map { Cheese(id = 0, name = it) }
CHEESE_DATA
is an ArrayList. If we apply map
with the above function then should it not create a list of Cheese objects with id 0
and name it
. The result seems to be Cheese object with an incremented value for id and it
name. What am I missing?
https://github.com/googlesamples/android-architecture-components/blob/6248bed977e7a82d6f3199e8a940a39b7d6f051c/PagingSample/app/src/main/java/paging/android/example/com/pagingsample/CheeseDb.kt#L54mics
10/25/2018, 5:58 PMclass Foo<T extends Enum<T>> {
Foo(Class<T> type) {}
}
enum FEnum {
BLAH
}
and then I try to instantiate Foo
in Kotlin
fun main(args: Array<String>) {
val foo = Foo(FEnum::class.java) // works ok, but have to hard-code enum class name here
val type: Class<out Enum<*>> = FEnum::class.java
val bar = Foo(type) // Error: doesn't work when class is obtained dynamically
}
How can I modify the Kotlin code, passing type
as some Class
, so that Foo
constructor accepts it?Steven McLaughlin
10/26/2018, 7:43 PMkarelpeeters
10/29/2018, 3:03 PMlist.fold(mapOf()) { a, c -> a + c }
jasoet
10/30/2018, 1:34 AMEnrico Hofmann
10/30/2018, 12:36 PMprabello
10/31/2018, 11:57 AMlet{::loveThePet}
but the return end up beign different and could not chain the calls, they were returning a KFunction instead of the resultMatheus
10/31/2018, 12:00 PMjcechace
10/31/2018, 1:21 PModay
10/31/2018, 1:52 PMepchris
10/31/2018, 3:57 PMprabello
10/31/2018, 7:16 PMSudhir Singh Khanger
11/01/2018, 6:26 AMval that : Int -> Int = { three -> three }
fit the definition val lambdaName : Type = { argumentList -> codeBody }
?
https://www.baeldung.com/kotlin-lambda-expressionsGabriel Machado
11/01/2018, 2:11 PMOverride by an inline function
, does this means it won't be inlined?oday
11/01/2018, 7:56 PMfind
to find the one and only item in a list where I know there is no repetition with, according to its ID?Hamza
11/02/2018, 5:26 AMdvlwj
11/02/2018, 8:25 AMdvlwj
11/02/2018, 8:41 AMJimmy
11/02/2018, 10:05 AMMatouš Skála
11/02/2018, 10:44 AMbodiam
11/02/2018, 11:10 AMbodiam
11/02/2018, 12:07 PMValV
11/03/2018, 10:23 AMscottiedog45
11/03/2018, 10:28 AMckchen
11/03/2018, 12:44 PMcoroutineContext[Job]
. Isn’t Job
an interface? Why can it be used for indexing? I have checked the source (public operator fun <E : Element> get(key: Key<E>): E?
of CoroutineContext
) and still don’t have a clue.ckchen
11/03/2018, 12:44 PMcoroutineContext[Job]
. Isn’t Job
an interface? Why can it be used for indexing? I have checked the source (public operator fun <E : Element> get(key: Key<E>): E?
of CoroutineContext
) and still don’t have a clue.karelpeeters
11/03/2018, 12:49 PMCtrl+B
on Job
?ckchen
11/03/2018, 12:50 PMpublic interface Job : CoroutineContext.Element
Job
is an interface, not an instance of Key<E>
. Why can it be passed to public operator fun <E : Element> get(key: Key<E>): E
?karelpeeters
11/03/2018, 12:54 PMelizarov
11/03/2018, 12:57 PMkarelpeeters
11/03/2018, 1:01 PM[Job]
?ckchen
11/03/2018, 1:04 PMpublic companion object Key : CoroutineContext.Key<Job>
in Job
. So, why not coroutineContext[Job.Key]
?elizarov
11/03/2018, 1:05 PMJob.Key
. But since Key
is a companion object to Job
, simply using Job
works, too.ckchen
11/03/2018, 1:06 PMkarelpeeters
11/03/2018, 1:08 PMckchen
11/03/2018, 1:11 PMelizarov
11/03/2018, 3:31 PMckchen
11/04/2018, 12:52 AM