benny.huo
04/09/2020, 7:09 AMfun main() {
val a = ::x
val b = ::x
val c = ::x
val d = ::x
}
fun x(){
}
Pascal How
04/09/2020, 11:24 AMbuildList
and I was wondering if there is a way to use it without having to write
@ExperimentalStdlibApi
everywhere.Antanas A.
04/09/2020, 12:03 PM@ExplicitOnly public expect open class CancellationException(message: String?) : IllegalStateException
spand
04/09/2020, 1:38 PMAshish Kumar Joy
04/09/2020, 2:54 PMSandy
04/09/2020, 3:23 PMWukongRework.exe
04/09/2020, 8:51 PMbod
04/10/2020, 11:50 AMforEach
on collections but with a lambda with the element as a receiver (instead of it
)?Joshua
04/10/2020, 4:31 PMviewModel.toolbarViewConfig.title.value = "What do you want to do?"
Fragment B:
activityViewModel.toolbarViewConfig.title.value = "Make $$$"
More Code Fragment A:
val viewModel = ViewModelProvider(activity!!)
.get(MainActivityViewModel::class.java)
viewModel.toolbarViewConfig.title.value = "What do you want to do?"
viewModel.toolbarViewConfig.isMenuVisible.value = true
return inflater.inflate(R.layout.fragment_home, container, false)
More Code Fragment B:
val viewModel = ViewModelProvider(this).get(GoOnlineViewModel::class.java)
val activityViewModel = ViewModelProvider(activity!!).get(MainActivityViewModel::class.java)
val binding = DataBindingUtil.inflate<FragmentSellerGoOnlineBinding>(
inflater, R.layout.fragment_seller_go_online,
container, false
).apply {
this.lifecycleOwner = viewLifecycleOwner
this.viewModel = viewModel}
activityViewModel.toolbarViewConfig.title.value = "Make $$$"
activityViewModel.toolbarViewConfig.isMenuVisible.value = false
viewModel.navigationCommand.observe(viewLifecycleOwner, Observer {
when(it) {
is <http://NavigationCommand.To|NavigationCommand.To> ->
Navigation.findNavController(requireView()).navigate(it.directions)
}
})
return binding.root
I'm not able to override the value viewModel.toolbarViewConfig.title.value
in fragment BAnaniya
04/10/2020, 5:16 PMyodgor777
04/10/2020, 7:14 PMEdoardo Luppi
04/11/2020, 8:33 AMvoben
04/11/2020, 12:30 PM*
or is it prefered to write out all import statements?Erik Dreyer
04/11/2020, 3:19 PMAbinandhan
04/11/2020, 3:29 PMCLOVIS
04/11/2020, 4:41 PMSomething<?>
to say that the generic is ignored. Is there any similar syntax in Kotlin? If so, where can I find documentation that explains how to use it?Ofir Bar
04/11/2020, 7:45 PMparent
which is a Person
type can just call the children
variable as like this list is a part of it?
3. I am also not sure how a Person
instance is passed to the constructor of a class which is Person
Source: https://kotlinlang.org/docs/reference/classes.htmlAnimesh Sahu
04/12/2020, 12:11 PMinline fun <reified T : Any> T.ext() "where T::class.isSealed" {}
liminal
04/12/2020, 4:44 PMenum class MyType { A, B, C }
data class MyTypeWrapper(val id: String, val type: MyType)
// existing code to order types based on some business rules
fun mapToOrderedTypeList(unordered: List<MyType): List<MyType> { return ... }
How do I order a list of `MyTypeWrapper`s based on order of their `type`s?Joshua
04/12/2020, 10:20 PMEdoardo Luppi
04/13/2020, 9:28 AMMichael de Kaste
04/13/2020, 11:17 AMtypealias Point = Pair<Int, Int>
val (axis1, axis2, pointConstruct) = when(horizontal){
true -> Triple(0..height, 0..width, {a1, a2 -> Point(a1, a2)})
false -> Triple(0..width, 0..height, {a1, a2 -> Point(a2, a1)})
}
Instead of telling me: Type cannot be infered
on a1,a2 in any of both lambdas, it simply states that Point is unreachable code. Alongside; it states that pointConstruct is a (Nothing, Nothing) -> Point
function
simply declaring:
val pointConstruct = {a1, a2 -> Point(a1, a2)}
will correctly tell me that a1 and a2 cannot be infered.
Why does it infer a (Nothing, Nothing) -> Point
in the deconstructed lamba, but a compile error on the single line one?wasyl
04/13/2020, 11:27 AMallWarningsAsErrors
but allow deprecation warnings? allWarningsAsErrors
is nice, but it prevents us from using @Deprecated
annotation to provide seamless code migrations 😕Mikael Alfredsson
04/13/2020, 5:24 PMdata class B(val i: Int)
data class A(val b: B)
class Test {
var a: A? = A(B(1))
fun get(): Int {
return a?.b.i ?: -1
}
}
the expression a?.b.i
must in kotlin be written as a?.b?.i
but in reality, if a
isnt null, we know that b
must contain i
(in Swift i think the former expression is valid)Tmpod
04/13/2020, 8:19 PMEnock Kalya
04/14/2020, 5:55 AMJaymin.Kim
04/14/2020, 7:47 AMinterface Base { fun foo(): Int }
object A {
fun createBase(): Base =
object : Base { override fun foo(): Int = 1 }
}
object B : Base by A.createBase() {
override fun foo(): Int {
// CANNOT access 'super', how to access instance created with 'createBase()' ?
return super.foo() + 1
}
}
Paul Woitaschek
04/14/2020, 3:01 PMw: Opt-in requirement marker kotlinx.coroutines.FlowPreview is unresolved. Please make sure it's present in the module dependencies
for exampletylerwilson
04/14/2020, 3:46 PMOfir Bar
04/14/2020, 5:34 PMval arrayList : ArrayList<String> = arrayListOf()
for(person in 0..listOfPersonsIndex){
arrayList.add(person[i])
}
I would like to no do that declaration of empty arraylist and the assign it.
Is there a cleaner way to immediately assign a value for it in the stdlib?