What I want to do is to add an object in array something like code below, but my Ide returns some errors, I don't understand what the problem is
val sachmelebi = [
{
name: 'ხინკალი',
link: 'https://www.google.com/search?q=ხინკალი&oq=ხინკალი&aqs=chrome..69i57j46j0l6.1143j0j9&sourceid=chrome&ie=UTF-8'
},
{
name: 'მწვადი',
link: 'https://www.google.com/search?q=მწვადი&oq=მწვადი&aqs=chrome.0.69i59j0l7.983j0j9&sourceid=chrome&ie=UTF-8'
},
{
name: 'მაკარონის წასახემსებელი',
link: 'https://gemrielia.ge/recipe/6594-xraSuna-makaronis-wasaxemsebeli-romelic-wuTebSi-mzaddeba/'
}
CodePudding user response:
The code snippet provided in the question is not valid Kotlin syntax. I would suggest to create a data class for your entries and then store them in a list. Below you can find an example:
data class Entry( // use a better name than "Entry"
val name: String,
val link: String
)
val sachmelebi = listOf(
Entry(
"ხინკალი",
"https://www.google.com/search?q=ხინკალი&oq=ხინკალი&aqs=chrome..69i57j46j0l6.1143j0j9&sourceid=chrome&ie=UTF-8"
),
Entry(
"მწვადი",
"https://www.google.com/search?q=მწვადი&oq=მწვადი&aqs=chrome.0.69i59j0l7.983j0j9&sourceid=chrome&ie=UTF-8"
),
Entry(
"მაკარონის წასახემსებელი",
"https://gemrielia.ge/recipe/6594-xraSuna-makaronis-wasaxemsebeli-romelic-wuTebSi-mzaddeba/"
)
)
