Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
131 views

I maintain an application which helps users to track the progress of an activity in real time. In essence, we represent the state of said activity as a data class in the Android mobile app. Every time ...
argenkiwi's user avatar
  • 2,476
2 votes
1 answer
62 views

I want to use a data class with a property that has a default value in the constructor based on another constructor parameter. It works exactly as I want it if I use a normal (non-data) class: import ...
k314159's user avatar
  • 12.4k
1 vote
1 answer
111 views

I have a data class like this: data class Calculation( val calculationType: String = "Multiplication", // or "Division" val firstOperand: Int, val secondOperand: Int, ...
BenjyTec's user avatar
  • 12.6k
0 votes
3 answers
133 views

I have encountered a problem while trying to resolve problem with sensitive info in application logs — we have quite large data class object that at some time in processing flow we log. Problem is ...
user avatar
-1 votes
1 answer
448 views

I am trying to define a dataclass for my model in the same class of the model, where i have defined the table. this is my model class, from dataclasses import dataclass, field from sqlalchemy import ...
inspironman's user avatar
1 vote
2 answers
241 views

I wanna write a nice TimestampMixin class for my project, I hope it can: created_at: autonow when creation, and never change since that updated_at: autonow when creation updated_at: auto update ...
steveflyer's user avatar
1 vote
0 answers
27 views

Edit: The "already answered answer" doesn't get me the values of the data class object. I can only access the field name and the order id, but NOT the value (here "0", "A"...
rescuemod's user avatar
0 votes
1 answer
74 views

I have an ArrayList val tasks = remember { mutableStateListOf<TaskItem>() } where the TaskItem is @Keep @Parcelize data class Task( var task: String, var done: Boolean = false ) : ...
Mark Delphi's user avatar
  • 1,809
1 vote
1 answer
112 views

Is there a way of mimicking Kotlin's data class 'copy()' in C++ ? This allows copying the object and modify specific parts of it within a single expression, see Kotlin example: data class SomeData(val ...
foo's user avatar
  • 631
-1 votes
1 answer
203 views

I have data class. I have inserting the room database this data class. it has string type. But I want to use back. I have calling the data. It has string. But I want to convert the data class type. ...
rasim altuntaş's user avatar
0 votes
2 answers
796 views

data class Thermostat( // ... other properties @SerializedName("units") private var _units: String?, // Fahrenheit, // ... other properties ) : Serializable { var units:...
Mohammad Taqi's user avatar
-1 votes
1 answer
262 views

I've been working on overriding the equals() from Any class. But in the below code. I'm confused why "if (other is Person)" is necessary to get the "if(this.firstName == other.firstName)...
Raghul G's user avatar
4 votes
2 answers
3k views

Given a data class with a nullable field, why can't I construct it by only passing the non-nullable fields ? I have already seen this related question. What is preventing Kotlin from implicitly ...
Harsha Limaye's user avatar
0 votes
0 answers
141 views

Is there a way like transient keyword in kotlin that will equals all other attribute except a boolen var As I have numerous attributes,I thought there must be a keyword for it. Product.kt @Parcelize ...
Taimoor Khan's user avatar
0 votes
1 answer
540 views

Best practice to omit optional parameter in a data class when its assigned null? Example: data class xyz(val a:String ?,val b: String?, val c: String?= null) if c = null, then data class xyz(val a:...
kk2004's user avatar
  • 1
0 votes
1 answer
66 views

I am currently developing an app in Dart/Flutter and I am facing one issue with my data class to handle my GraphQL response. My User class is defined as following: import 'package:json_annotation/...
Ala Ha's user avatar
  • 59
1 vote
1 answer
735 views

I am currently working on a Flutter project where I am trying to create a data class for a User that involves an Image property. In TypeScript, I have a union type Image that can be either a boolean ...
rajput-hemant's user avatar
0 votes
2 answers
268 views

I am calling an API using RxJava and Retrofit and storing the data in data class of kotlin. While calling the api, an error is thrown : java.lang.IllegalStateException: Expected BEGIN_ARRAY but was ...
Dishita Shah's user avatar
0 votes
1 answer
847 views

Here's the codes that is working: data class Abc( val a: String, val b: String, val c: String, val d: D ) { data class D( val e: String, val f: String, val ...
user3768495's user avatar
  • 4,717
-1 votes
1 answer
423 views

Here is my code:: data class User(val id: Int, name: String) fun getUsers(): List<User> Now, I want to add an age field to the User data class, but I'm concerned about two things: Breaking the ...
David Lev's user avatar
1 vote
1 answer
151 views

Model Class public struct Products : Codable { let data: [ProductData] let error: Bool let message: String } public struct ProductData : Codable { let id, category, subCategory, name, ...
SasidharanIOS's user avatar
2 votes
1 answer
1k views

I am from Swift background. Swift has both "value" type & "reference" type support, I am bit curious. Does Kotlin have similar concepts? By default, any class is a reference ...
Nasir's user avatar
  • 1,899
1 vote
1 answer
44 views

This is my problem, imagine you need to show a table of clients, there you only need to show about 4 fields of the data class Client: Name Last Name Birthday Id But when I go to the details of a ...
Antonio Giler's user avatar
2 votes
0 answers
2k views

I would like to understand the best practices in creating Kotlin entities with JPA. First, this is a part of my build.gradle.kts. I have added both plugin.jpa and plugin.allopen plugins { id("...
Hasan Mhd Amin's user avatar
0 votes
0 answers
1k views

I've implemented several projects with spring boot and java. Now I'm evaluating, if I could do it with kotlin. I am struggling with @ConfigurationProperties and data classes. Simple example: api: ...
Thilo Schwarz's user avatar

1
2 3 4 5
8