1

I am new one about KotlinPoet. Actaully, I want to generate code lines like the bellow with KAPT. There is not proper sample to generated init 'map' data. Is there anyone help me?

===> like this

package com.example.kotlintest

import kotlin.Pair
import kotlin.String

class InitMapData {
    val activityMap = mapOf<String, Pair<String,String>>(
        "aa" to  Pair("bb","cc"),
        "dd" to  Pair("ee","ff")
    )
  
}
mpx
  • 3,081
  • 2
  • 26
  • 56
  • Your question feels poorly researched, sorry. Have you read the [documentation](https://square.github.io/kotlinpoet/)? Have you searched through the [KDoc](https://square.github.io/kotlinpoet/1.x/kotlinpoet/) to see which APIs might help? Have you looked into the library sources, especially the [unit tests](https://github.com/square/kotlinpoet/tree/master/kotlinpoet/src/test/java/com/squareup/kotlinpoet), to see if there are any examples of similar use-cases? – Egor Jul 30 '20 at 15:00
  • Thank you for your consideration even my question was poor. Anyway... I figured it out by myself. There was a problem about using FunSpec.builder().addStatement() and It 'double quotes' string Format. – Seokwon Kim Aug 01 '20 at 01:30

1 Answers1

0

Use .paramterizedBy off the PropertySpec.builder

it's in the docs under the "%T" for types section.

West_JR
  • 372
  • 2
  • 11