0

I have the following:

class Here {
  public id: string = "here"
  public dao: string = "good"

 good(): void {

 }
}

In the good function, I need to write a code that returns the keys and values of public variables of Here. Since this is assemblyscript, It's really hard. I don't want to repeat id and dao in good since this is easy example. In the real world, I got 20 public variables and repeating them 2 times is horrible.

Any idea ? I'd highly appreciate it.

TachyonicBytes
  • 700
  • 1
  • 8
Giorgi Lagidze
  • 773
  • 4
  • 24
  • Welll, there is nothing to clarify. If you understand assemblyscript, you would understand what I am asking. I dont care about private vars. And inside good, all I need is to get all public keys – Giorgi Lagidze Mar 10 '23 at 08:21
  • There seems to be work[1] better reflection, which would lead to `Object.keys()`. The only options I see are: 1. Your own `visitor-as` transform with custom compilation code for `Here` (hard) 2. Serialize using `json-as` and parse the json string for the values you need (possibly easier than it seems) and 3. some use of `@operator("[]")` overloading (you may have to still repeat), depending on what you want to do. [1] https://github.com/AssemblyScript/assemblyscript/issues/292 – TachyonicBytes Mar 11 '23 at 13:16

0 Answers0