Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Object inside of an array

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=%E1%83%AE%E1%83%98%E1%83%9C%E1%83%99%E1%83%90%E1%83%9A%E1%83%98&oq=%E1%83%AE%E1%83%98%E1%83%9C%E1%83%99%E1%83%90%E1%83%9A%E1%83%98&aqs=chrome..69i57j46j0l6.1143j0j9&sourceid=chrome&ie=UTF-8'
    },
    {
      name: 'მწვადი',
      link: 'https://www.google.com/search?q=%E1%83%9B%E1%83%AC%E1%83%95%E1%83%90%E1%83%93%E1%83%98&oq=%E1%83%9B%E1%83%AC%E1%83%95%E1%83%90%E1%83%93%E1%83%98&aqs=chrome.0.69i59j0l7.983j0j9&sourceid=chrome&ie=UTF-8'
    },
    {
      name: 'მაკარონის წასახემსებელი',
      link: 'https://gemrielia.ge/recipe/6594-xraSuna-makaronis-wasaxemsebeli-romelic-wuTebSi-mzaddeba/'
    }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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=%E1%83%AE%E1%83%98%E1%83%9C%E1%83%99%E1%83%90%E1%83%9A%E1%83%98&oq=%E1%83%AE%E1%83%98%E1%83%9C%E1%83%99%E1%83%90%E1%83%9A%E1%83%98&aqs=chrome..69i57j46j0l6.1143j0j9&sourceid=chrome&ie=UTF-8"
    ),
    Entry(
        "მწვადი",
        "https://www.google.com/search?q=%E1%83%9B%E1%83%AC%E1%83%95%E1%83%90%E1%83%93%E1%83%98&oq=%E1%83%9B%E1%83%AC%E1%83%95%E1%83%90%E1%83%93%E1%83%98&aqs=chrome.0.69i59j0l7.983j0j9&sourceid=chrome&ie=UTF-8"
    ),
    Entry(
        "მაკარონის წასახემსებელი",
        "https://gemrielia.ge/recipe/6594-xraSuna-makaronis-wasaxemsebeli-romelic-wuTebSi-mzaddeba/"
    )
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading