Written below is a simple scala code.
var variableName:String = "Mickey"
var Mickey:String = "Mouse"
Is there any way to replace Mickey in the second line by the value of variable variableName? If not, why?
Edit: Although my purpose of asking this question is to understand how/why it can/cannot be done, I would like to write about how I was introduced to this problem. I wrote the following piece of code.
class VertexProperty(var id:Long) extends Serializable
The variable name id is hard-coded here, but I want to put a variable name which gets generated at run-time(for e.g : an input from user).
Below is a pseudo-code which I want to write in scala.
//pseudo-code
1. Ask user for variable's name and type. <user types xyz and String>
2. Define a class with the following definition,
class VertexProperty(var xyz:String) extends Serializable