I want to create a variable with dynamic value in it. Something like this:
String myAlphabet = 'c';
List myList = [
'a',
'b',
getMyAlphabet()
];
String getMyAlphabet(){
return myAlphabet;
}
When I access myList, I should get ['a','b','c']. But at one point of my program, the value of myAlpabet is changed to 'd'. At that point when I access myList I should be getting ['a','b','d'] but instead I'm still getting ['a','b','c'].
How do I make it so that everytime I access myList, I will be getting the latest value instead of the value when it is first initialized? Thank you in advance.
