I'm trying to access a variable from another class. The usual way would be:
in Class A
var something = ClassB().element
in Class B
val element = "hi"
Is it also possible to address element not by its name directly, but when I have the name stored in a string? So I have a string that holds
var name = "element"
and want to do something like
var something = ClassB().name //(this doesn't work)
The reason I'm asking is because I have a class in which I do some pitch processing and another class in which I store all of my pitch data in float arrays (the Hz values of different musical notes for different tunings of different instruments)
In the class I do my pitchprocessing in I want to select the right float array depending on a user selection (made with a spinner), which I "translate" with a map (so for example the spinner says "Standard Tuning" and the according array would be called "guitarStandard", in my map "Standard Tuning" would be the key and "guitarStandard" the according value). To not hardcode the different cases in which I need different arrays with if statements, I simply want the name of the array stored in a string by getting the correct value of my map and adress it that way.
I feel like that should be either super simpel or I'm thinking about it the completely wrong way, can someone help out? Thanks