Quazi Irfan
03/25/2022, 7:06 PMNathan Kleinschmidt
03/27/2022, 3:04 PMimplementation(files(./dependency))
. My question is which path exactly do I need to reference?Jan
03/27/2022, 3:06 PMLastExceed
03/28/2022, 10:34 AMrepeat(10) {
foo()
delay(500) //problem: causes trailing delay
}
i could of course do this:
foo()
repeat(10) {
delay(500)
foo()
}
but it looks kinda ugly to meNicolai
03/29/2022, 6:41 AMdata class Action(
val actionGuid: String,
val actionType: String,
val allowClose: Boolean,
val body: String,
val deepLink: String,
val deepLinkId: String,
val deepLinkSubId: String,
val deepLinkText: String,
val fuxiActionVersion: Int,
val imageUrl: String,
val isAutoClose: Boolean,
val isDeleteFromCache: Boolean,
val isHidden: Boolean,
val isShowClose: Boolean,
val pageId: String,
val questions: List<Any>,
val submitText: String,
val submitUrl: String,
val surveyId: String,
val theme: String,
val title: String,
val validFromUtc: String,
val validToUtc: String
)
and another data class
@kotlinx.parcelize.Parcelize
data class FuxiNotification(
val actionGuid: String,
val actionType: String,
val allowClose: Boolean,
val body: String,
val deepLink: String,
val deepLinkId: String,
val deepLinkSubId: String,
val deepLinkText: String,
val fuxiActionVersion: Int,
val imageUrl: String,
val isAutoClose: Boolean,
val isDeleteFromCache: Boolean,
val isHidden: Boolean,
val isShowClose: Boolean,
val pageId: String,
val theme: String,
val title: String,
val validFromUtc: String,
val validToUtc: String
) : Parcelable
What would be the way to do this in a smart way so I can map Action to FuxiNotification easily? 🙏Vitali Plagov
03/29/2022, 12:50 PM// java
var words = List.of("one", "two", "three");
Function<Integer, Predicate<String>> lengthFun = (minLength) -> (str) -> str.length() > minLength;
Predicate<String> isLongerThan2 = lengthFun.apply(2);
Predicate<String> isLongerThan3 = lengthFun.apply(3);
var longerThan2 = words.stream().filter(isLongerThan2).collect(Collectors.toList());
var longerThan3 = words.stream().filter(isLongerThan3).collect(Collectors.toList());
I know that these predicates are pretty straightforward and can be inlined straight into the filter { }
function. But I’m more interested in a general approach of how to do it.Comic Playz
03/29/2022, 2:00 PMchansek
03/29/2022, 6:04 PMabstract class SomeLibraryClass<T> {
abstract fun test(key: String): T
}
class Item<T : Enum<T>> : SomeLibraryClass<T>() {
override fun test(key: String): T {
return enumValueOf(key)
}
}
Can't make T as reified
or test
as inline. How can I inherit the library class for enum?Kamila
03/29/2022, 6:30 PMval bankAccount: BankAccount? = null
When I parse it to DTO object, which takes bankAccount as String, I use bankAccount.toString()
which, in case of null, ends up being “null” String on DTO object.
How should I approach it, so the value is actually null or property is omitted?Tomas Kormanak
03/30/2022, 9:34 AM@Seriazlizable
annotation constructor can not have parameter which is not property
@Serializable
class Document(
name: String,
) {
var name: String = name
private set
}
César
03/30/2022, 12:46 PMval courses: Collection<Course> = gson.fromJson(response.string(), Collection<Course>::class.java)
(the Collection<Course>::class.java
part)poohbar
03/30/2022, 5:03 PMval value = if (someCondition) {
// compute value
} else {
null
}
the else branch is always just null
.. is there a more idiomatic way to write this?Matt Yokan
04/01/2022, 2:47 AMJukka Siivonen
04/01/2022, 9:29 AMJukka Siivonen
04/01/2022, 10:19 AMhfhbd
04/01/2022, 5:21 PMDamiano Petrungaro
04/02/2022, 12:22 AMandodeki
04/02/2022, 1:39 AM[Item(int=1, item=Category1, ItemList={Name=[]})]
null
data class Item(
var int: Int,
var item: String,
var ItemList: Map<String, List<Item>>
)
var defaultcategory = listOf(
Item(1, "Category1", mapOf("Name" to listOf<Item>()))
)
var defaultItems = listOf(
Item(1, "Item1",mapOf("Name1" to defaultcategory)),
Item(2, "Item2",mapOf("Name2" to defaultcategory))
)
defaultItems.forEachIndexed { index, element ->
print(element.ItemList["Name1"])
print("\n")
}
Mark
04/02/2022, 4:09 AMString.replace(String, String)
does it ever make sense to wrap it with if (String.contains(String))
for example if the occurrence is very unlikely? Or perhaps it depends on the target architecture?Junjie Wu
04/02/2022, 2:00 PM4
instead of 13
?
fun add(a: Int, b: Int, cumulate: (Int) -> Unit): Int {
cumulate(a + b)
return a
}
fun main() {
var answer = 0
answer += add(4, 5) { answer += it }
println(answer)
}
my guess is that answer += x
equals to answer = answer + x
where the second answer equals to 0, but I can’t find any prove on docAsq
04/02/2022, 2:28 PMW
in the example below) with more than one constraint, if a class delegates some of its implementation details?
e.g.
class DirectedEdgeWeighted<W> private constructor (val de: DirectedEdge, val w: W, val wAccretion: (W, W) -> W): DirEd by de where W: Any, W: Comparable<W> { ... }
produces syntax errors, even after trying several permutations in how the part after the constructor is declared, and before the beginning (say, data class
) too. It is important that DirectedEdgeWeighted
is-a DirEd
but not is-a DirectedEdge
so inheritance is not a solution. This issue is interesting on the basis of syntax principles, so please let's ignore the possibility of making inheritance feasible. I could hypothetically drop W: Any
as a workaround, yes, but a workaround is not the goal of the answer that I seek. Reassuming, without the example above: my question is:
is there a manner to use a type variable ("generic") with more than one constraint, if a class delegates some of its implementation details?
Thanks for your kind and analytical interest 🙂TwoClocks
04/02/2022, 9:36 PMUnresolved reference
when building (either in idea, or gradle)Kevin
04/04/2022, 4:06 AMactivity_main.xml
in form of <com.test_project.library.buttons.TestButton/>
, it did works perfectly, but i found out that i cannot override the text value because the android:text
doesn't appear from suggestion.
is this because the effect from inflating the views? or there is something that missing from the custom views class that i didn't declare it first so i cannot put text value in activity_main.xml
?Kamila
04/04/2022, 7:19 AMclass Something(val name: String) {
companion object {
fun toDto(): Dto(name)
}
}
data class Dto(val name: String)
But I would prefer to have possibility to write:
Dto.from(foo: Something) = Dto(name = foo.name)
Is it possible?LastExceed
04/04/2022, 11:28 AMval buffer = ByteBuffer.allocate(4450)
intellij says the inferred type of this is val buffer: (ByteBuffer..ByteBuffer?)
what does that mean? this isn't even valid code when i try to type this out myself. the code compiles fine on my machine, but jitpack.io fails because of a type mismatch. what is going on here?Joe
04/04/2022, 8:09 PMThis declaration overrides deprecated member but not marked as deprecated itself. This deprecation won't be inherited in future releases. Please add @Deprecated annotation or suppress
. This warning didn't occur in 1.6.10 and don't see mention of it in the release notes. is this expected? (we can suppress/remove the warning ok, but build with -Werror so this is backwards incompatible for us)Serena Xu
04/05/2022, 2:11 AM@Json(name = "order_id") val orderId: Int,
@Json(name = "new_delivery_window_id") val newDeliveryWindowId: Int?,
@Json(name = "new_delivery_window_uuid") val newDeliveryWindowUUID: UUID?,
@Json(name = "new_delivery_address_id") val newDeliveryAddressId: Int?,
@Json(name = "otc_items") val otcItems: List<CartOTCItem>?,
@Json(name = "fills") val fills: List<PrescriptionFulfillment>?,
@Json(name = "promo_items") val promoItems: List<PromoItem>?,
@Json(name = "reason") val reason: String?,
@Json(name = "note") val note: String?,
@Json(name = "subtotal") val subtotal: Int?
My payload is:
{
"order_id": 980,
"new_delivery_window_id": 14,
"new_delivery_window_uuid": "8d",
"new_delivery_address_id": 136,
"note": "testing note",
"subtotal": 1000,
"reason": "testing reason"
}
I got error:
com.squareup.moshi.JsonDataException: Expected an int but was NULL at path $.createdBy
.
I am a bit confused of createdBy
. Anyone has any clues on this ?zokipirlo
04/05/2022, 10:36 AMtoMetadata
to call all buildMetadata
function and merge lists?
interface Meta {
fun buildMetadata(): List<String>
}
interface FeatA : Meta {
override fun buildMetadata(): List<String> = listOf("A")
}
interface FeatB : Meta {
override fun buildMetadata(): List<String> = listOf("B")
}
class ObjC: FeatA, FeatB {
override fun buildMetadata(): List<String> = emptyList()
fun toMetadata(): List<String> // //What to do here to combine all lists (metadata) from interfaces?
}
fun main() {
val c = ObjC()
println(c.toMetadata()) // expecting ["A", "B"]
}
Kenneth
04/05/2022, 10:57 AM<http://com.my|com.my>.package.MyClass
in code? I refactored some packages and it got a bit messy, want to change it back to only MyClass.Nowon Lee
04/05/2022, 4:25 PMNowon Lee
04/05/2022, 4:25 PMStephan Schroeder
04/06/2022, 6:54 AM