Vararg function parameter with default value?


Is there a way to specify a default value for a vararg type parameter of a function?
So basically, I would like to do this:

fun AppCompatActivity.startActivityForResultWithTransition(intent: Intent, requestCode: Int, vararg sharedViews: View? = null)

In order, to call it from my activity like:

 startActivityWithTransition(FundingSummaryActivity.getStartIntent(this), binding.onboardingToolbar, binding.onboardingProgress, binding.readyToStart);


i am sorry i don’t understand.

Vararg parameter is optional, why you should define a default value for an optional parameter?

You can simply omit it.


vararg by definition already has a default, which is an empty array.