I have a function that returns ( groovy code)
[words: \"one two\", row: 23, col: 45]
In scala I change above to scala Map but then I am for
Having only two possible value types as in your example would allow to use the Either type with the sub-types Left and Right:
val m = Map("words" -> Left("one two"), "rows"-> Right(23), "cols"-> Right(45))
If you get back a value from the map, you can check what you have, e.g. with pattern matching or using isLeft and isRight, and "unwrap" it accordingly.