Hello Team, I have a suspend function named 'build...
# android
p
Hello Team, I have a suspend function named 'build' that returns Either<Model, Error> and I'm this using member reference as: val res = builder::build where 'res' type = KSuspendFunction0<Either<Model, ApiError>> However, I am expecting 'res' type should be: KSuspendFunction0*<Model?,* <Either<Model, Error>>> whereas, in a normal scenario when I am calling: val res = builder.build() the 'res' type is as expected as Either<Model, Error>. Am I missing something?
e
builder::build
is bound to
builder
p
Sorry, I did not get many hints. Could you please elaborate?
p
I'd change the return type and calling way, It did not help much.
e
if the function call is
builder.build()
, then
builder::build
also takes no arguments. it is bound to `builder`: the receiver is already pre-set to
builder
, as in
{ builder.build() }
. why would you expect the type to contain an additional argument type?
on the other hand (assuming the type is named
Builder
),
Builder::build
is not bound to an instance, so it does take an argument, similar to
{ builder -> builder.build() }
. note the difference between a type and an instance on the left-hand side of
::
p
I am passing builder::build call to a generic method as a param, that accepts:
Copy code
modelBuilder: suspend (model: T?) -> Either<T, Error>
e
if the function is normally called by
builder.build()
then where do you expect the
model
parameter to go?
✔️ 1
p
Got it, I was missing an optional nullable param. Thanks much.