Hello friends,
I’m currently trying to use a type alias to make my code more readable but I fail. My code is:
type VariableName = String
type Environment = Map[VariableName, Int]
Then i have a function that gets environment : Environment
as parameter and there I want to insert a value into the environment like:
environment("a" -> 5)
My compiler doesn’t like that and says:
“Type Mismatch:
Found: (String, Int)
Required: (Objectname.VariableName)
(which expands to) String”
I’m confused because I gave it a string. Anyone knows how I need to declare that VariableName so it gets accepted?
Thanks in advance!
Edit: My question just changed, as I tried to remove the type alias and exchange it with a simple string.
I think it has something to do with how I used it:
case _ : Int => environment("a" -> 5)
What works is
case _ : Int => environment("a")
So maybe it kinda gets that the matched int should be the right side in the map? I will test and close the question if so.