How to varargs to a map inside a custom Exception

Hi all,

I need to pass the following varargs to a map. How can I do that? I come from the java background.

open class DomainException(msg: String, vararg val msgParams: String) : Exception(msg)

I don’t really understand you question. What do you want to do? You can use msgParams as if it was declared as msgParams: Array<String>. There is nothing special about it. vararg just changes how a function (or in this case the constructor) is called.

2 Likes