Is there any hard and fast rule of when to declare...
# announcements
h
Is there any hard and fast rule of when to declare functions as inline and when not declare inline
k
If they're small and have a function parameter yes, otherwise no.
And reified type parameters of course, you don't even have a choice there.
m
And if you pass a lambda which is executed immediately.
s
One reason to make a function that take a lambda an
inline
function is to support
suspend
functions better. If your function or its lambda paramter is not
inline
, the body of the lambda on the call-site is not ’suspend’able. This means, you can’t call
suspend
functions in the lambda. If you function and its lambda parameter are
inline
, the lambda provided by the calling code (on the call-site) is still suspendable, ie it can call
suspend
functions.