Vitali Plagov
04/23/2020, 1:05 PM/[()\/]/g
that matches (
,)
,/
anywhere in a string. Why exactly the same pattern doesn’t work with Kotlin when I pass it to the Regex
?Animesh Sahu
04/23/2020, 2:11 PMid 'org.jetbrains.kotlin.jvm' version 1.+
and it fetches 1.4-M1, and that version of kotlin-stdlib-jdk8 dependency is not available, it errors:
Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4-M1.
Possible solution:
- Declare repository providing the artifact, see the documentation at <https://docs.gradle.org/current/userguide/declaring_repositories.html>
Justin Breitfeller
04/23/2020, 4:12 PMMyJavaClass::hasData
as an IsStateRunningCheck
argument I get the following error. Found KFunction1 and not my interface. Is this an instance of SAM conversion not working properly or is there something I can do to make this possible.
@FunctionalInterface
protected interface IsStateRunningCheck<T> {
boolean isStateRunning(T state);
}
For instance:
fun myFooMethod(stateCheck: IsStateRunnningCheck<Int>) { ... }
fun test() {
myFooMethod(MyJavaClass::hasData) // fails to compile
myFooMyethod( { it.hasData() }) // works fine
}
// I don't think it matters if this is java or not
class MyJavaClass<Int> {
boolean hasData(int x) { return true; }
}
Animesh Sahu
04/23/2020, 4:22 PMLuis Munoz
04/23/2020, 5:20 PMSlackbot
04/23/2020, 10:07 PMSlackbot
04/24/2020, 9:51 AMJiri Bruchanov
04/24/2020, 1:20 PMSam Garfinkel
04/24/2020, 8:25 PMAhmed Mourad
04/25/2020, 1:58 AMczyzby
04/25/2020, 9:33 AMOptIn
annotation or compiler flags? Should I annotate my methods/files with @OptIn(ExperimentalContracts::class)
?Gopal S Akshintala
04/25/2020, 1:49 PMfun SLLNode?.sumListWith(node: SLLNode?, carry: Int = 0): SLLNode? =
when {
this == null && node == null -> if (carry == 0) null else SLLNode(carry)
this == null -> node.also { it!!.value += carry } // Smart cast doesn't work here.
node == null -> this.also { value += carry } // Works here.
else -> {
...
}
}
hnOsmium0x0
04/26/2020, 4:53 AMSlackbot
04/26/2020, 8:21 AMTim Malseed
04/26/2020, 10:13 AMJoan Colmenero
04/26/2020, 12:02 PMsteenooo
04/26/2020, 2:57 PMpablisco
04/26/2020, 5:41 PMMap
in Kotlin. What do y’all do?
https://twitter.com/pablisc0/status/1254465101224120324Colton Idle
04/26/2020, 6:14 PMmyobject.somethingInner.somethingNested.setter1 = true
myobject.somethingInner.somethingNested.setter2 = false
myobject.somethingInner.somethingNested.setter3 = false
That seems like a legitimate use case to me to not have to repeat so you can do
myobject.somethingInner.somethingNested.apply {
setter1 = true
setter2 = false
setter3 = false
}
I also read that this makes things thread safe. So while that sounds good. I don't know what that actually means. Is my first statement not thread safe?Peter Kucera
04/27/2020, 1:18 PMVincent Williams
04/27/2020, 4:15 PMKrish
04/27/2020, 5:10 PMabstract class CommonResponseParams (
val type: String,
val code: String,
val message: String,
@SerializedName("request_id")
val requestId: String,
val detail: CommonDetailsResponseObject?
)
And I have a more specific Response Params which has the Common Params on top of it
I wish to extend this data class with the abstract class above
data class GetCategoryAttributeResponse (
val commonDetails : CommonDetailsResponseObject,
@SerializedName("data")
val getCategoryData: CategoryAttributeResponseData
)
Krish
04/27/2020, 5:12 PMinterface Response extends CommonResponseParams {
// API endpoint specific params
}
user
04/28/2020, 9:30 AMakshay_b
04/28/2020, 1:27 PMobject : GenericType<Pair<F, S>>() {}
produces raw type of GenericType<Pair<? extends F, ? extends S>>
how to remove ? extends
Thanks in advance 🙂Antoine Gagnon
04/28/2020, 1:52 PM(1..10).filter {
it < 5
}
.map {
val double = it * 2
double*3
}
.map {
it.dec()
it + 5
}
2.
(1..10).filter {
it < 5
}.map {
val double = it * 2
double * 3
}.map {
it.dec()
it + 5
}
The coding convention suggests that when chaining calls you should put each call on a new line starting with a dot but I don’t how if it applies to lambdas and other {} thingsTwferrell
04/28/2020, 2:49 PMLastExceed
04/28/2020, 5:03 PM.toSentence()
? the difficult part is not having leading or trailing whitespacesChung
04/28/2020, 11:55 PMViewHolder
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return when (viewType) {
0 -> ViewHolder(CategoryHeaderBinding.inflate(LayoutInflater.from(parent.context), parent,false))
else -> ViewHolder(CategoryCardBinding.inflate(LayoutInflater.from(parent.context), parent, false))
}
}
it passes either CategoryHeaderBinding
or CategoryCardBinding
to ViewHolder
class ViewHolder(private val binding: CategoryCardBinding OR CategoryHeaderBinding) :
RecyclerView.ViewHolder(binding.root) {
}
How do I make ViewHolder
accepts binding
to be either CategoryCardBinding
or CategoryHeaderBinding
Thomas Nordmeyer
04/29/2020, 6:41 AMvar mapType
get() = map.mapType
set(value) {
map.mapType = value
}
I know we have Delegates but can those be used in a more simple way than my implementation above?Thomas Nordmeyer
04/29/2020, 6:41 AMvar mapType
get() = map.mapType
set(value) {
map.mapType = value
}
I know we have Delegates but can those be used in a more simple way than my implementation above?Sam Garfinkel
04/29/2020, 6:45 AMsetValue
and getValue
operators for whatever type map
is then you can use var mapType by map
Thomas Nordmeyer
04/29/2020, 7:24 AMvar mapType by proxy(map.mapType)
or even
var mapType proxies map.mapType
somehow generic. Quiet common use case when encapsulating 3rd party components.araqnid
04/29/2020, 8:45 AMvar mapType by proxy(map::mapType)
if you’re using it a lot, and then write it up as a suggestion for stdlib