I have a function like this: `public final GoogleS...
# announcements
s
I have a function like this:
public final GoogleSignInOptions.Builder requestScopes(Scope var1, Scope... var2) { }
I can call
.requestScopes(scope1, scope2, scope3)
without any problem. How can I translate a list of Scopes to call this function. I tried using only an
Array
, a
List
, to pass the first element and then a list. But nothing worked. Seems like I have to pass the expanded list. How can I achieve this when my list of scopes is stored inside a
List<Scope>
? Thanks!
a
you need to prefix an array with “*”, e.g.
requestScopes(scope1, *arrayOfScopes)
and you can convert a List to an Array with toTypedArray:
requestScopes(scope1, *(listOfScopes.toTypedArray()))
s
So it’s necessary to pass the first scope alone?
a
well, the method prototype you quoted there has separate (Scope,Scope…) args, so yes.
s
That’s what I thought, double checking. Thanks a lot! 🙂
a
(presumably to solve overload ambiguity)
s
I’d have to ask Google about this one 🤔