https://kotlinlang.org logo
#getting-started
Title
# getting-started
j

Jasmin Fajkic

09/30/2022, 5:23 PM
Hello guys. I am JS developer new in Kotlin world. Want to flatten list to single list. In JS i use simple recursive function that is seems does not work correctly. In thread is mock data how list looks like.
Copy code
[
    {
      id: 'some-id',
      children: [
        {
          id: 'some-id2',
          children: [
            {
              id: 'some-id3',
              children: [
                {
                  id: 'new-id',
                  children: [
                    {
                      id: 'new-id2',
                      children: null,
                    },
                  ],
                },
              ],
            },
          ],
        },
      ],
    },
    {
      id: 'some-id4',
      children: [
        {id: 'some-id5', children: [{id: 'some-i63', children: null}]},
      ],
    },
    {
      id: 'some-id',
      children: null,
    },
  ];
it is basically List<MyOwnType>. I want to flatten it to single list once i get it from server.
Ah made it 🙂 thx anyway 🙂
rubber duck 1
2 Views