r/Kotlin•
InnerTJR

List within a List

Hi,
What I'm trying to achieve by this is;

[Places] England, Scotland, New Zealand [Frute] Apple, Orange, Banana

where [Places] is a string in the list of myDictionary, and England, Scotland & New Zealand are a list from [Places] at the same index

var myDictionaryWords = mutableListOf<String>() var myDictionary = mutableListOf<List<Any>>(myDictionaryWords)

fun test() {
myDictionaryWords.add(0,"")
myDictionary.add(0, myDictionaryWords )
}

In my native tong language (Pure Basic) I would say this like the following;

Structure DICTIONARY   
    name.s   
    List words.s() 
EndStructure  

NewList dict.DICTIONARY()
AddElement(dict())
dict()\name = "Places" 
AddElement(dict()\words())
dict()\words = "England"
AddElement(dict()\words())
dict()\words = "Scotland"
AddElement(dict()\words())
dict()\words = "New Zealand"

Unfortunately on stack-overflow I was told my question was to simple and I should google, which I had googled and googled the last few hours googling.

Posted Sep 10, 2021, 11:09 AM UTC

19
Loading comments…