Is it possible to make an alias for item of an array in scala? The code below won’t work but something like that.
var str=new ArrayBuffer[String](10)
def alias = str(1)
alias="test"
print(alias)
The code below works and basically what I want to do with the code above. But I don’t want to type str(ALIAS) everytime I use this variable. I want shorter name
var str=new ArrayBuffer[String](10)
val ALIAS=1
str(ALIAS) = "test"
print(str(ALIAS))
Just use a standard setter syntax: