Hi all! I created a Kotlin file in my project that...
# android
s
Hi all! I created a Kotlin file in my project that is a data class that colds an array of questions and answers. I can't figure out how to access that array in my main activity! Any ideas? Thanks!
s
Can you post a sample from that data class?
t
Supposing this is your data class :
Copy code
data class Faq(val questions: List<Question>, answers: List<Answer>)
Create it with
Copy code
val qa = Faq(listOf(...), listOf(...))
Access it with
Copy code
val questions = qa.questions
✔️ 1
s
Would it be better implemented as a Hashmap?
d
A data class is not a static object it needs to be instantiated.