<Pass argument with multiple return points> Assumi...
# stackoverflow
u
Pass argument with multiple return points Assuming I have a function example() that has a parameter param: Int?. I would like to call it so that the argument can be passed with certain conditionals. To try to explain better, let's define the example() function: fun example(prev: Int, param: Int?) = doSomething(prev, param) So assuming that under certain conditions, the value passed as an argument can be null or any other value. Naturally, I would do something like this: val param = if (x() > 100) null else if (x() < 0)...