Just doing a sanity check ``` when(e) { is Strin...
# getting-started
r
Just doing a sanity check
Copy code
when(e) {
  is String, Int -> /*do stuff*/
}
It doesn’t appear that I can accomplish the above. Is that correct?
b
you can get it to compile with
is String, is Int -> /*do stuff*/
but I don't think the compiler is sophisticated enough to let you do operations on
e
common to both the
String
and
Int
APIs, so it's not all that useful. you just wind up with an
Any
type in
/*do stuff*/
r
@bissell Sorry, the example is high level. I just need the ability to check if
e
is one of two types. The second type calls for initialization, for some weird reason
If it helps, I’m checking if
Exception e
is
ConnectException
or
SocketTimeoutException
Just had to put
is
before the second one 🙄🤦‍♂️
b
Hahah took me awhile to figure out when I first did it too