aphex
03/30/2017, 1:45 PMfun fromActivity(activity: Activity?): Source = when {
activity != null && activity is FooActivity -> Source.FOO
else -> Source.UNKNOWN
}
Something tells me I don’t need the null check in the above code. Can I get rid of it and have the same exact behavior?robin
03/30/2017, 1:58 PMis
check won't succeed if activity
is null.activity
as a parameter to the when
expression then.aphex
03/30/2017, 2:03 PMrobin
03/30/2017, 2:06 PM&&
expression in your code so that it looks like this:
activity is FooActivity && activity != null
intelliJ will even tell you that the null-check is unnecessary 😉aphex
03/30/2017, 2:10 PMactivity
as an argument to when. Fix this lint-check, @jetbrains 😆robin
03/30/2017, 2:10 PM