It sucks a bit that `?.let {}` doesnt use the exte...
# javascript
s
It sucks a bit that
?.let {}
doesnt use the extension function when receiver is dynamic. Anyone found a pattern just as concise way to express it ?
g
what do you mean?
d
foo.let {}
does not call
kotlin.let
if
foo
has type
dynamic
Because with
dynamic
everything is dispatched as normal JS function calls.
(foo as Any?)?.let { }
should work though
s
Except I need it as
dynamic
in the lambda
d
Maybe just use an if then? 😄
s
Yeah thats what I am not quite satisfied with hence the question 🙂
d
Yeah I don't think you can do anything except cast to
Any?
outside and then back to dynamic inside.
g
ah, I see
I remember some discussion about this, as I remember only cast to Any will help
d
Well, that will fail if the object is
null
or
undefined
g
undefined of course
but why null cast to Any? doesnot work?
(foo as? Any)?.let{}
d
It doesn't? That's strange.
g
I see