<https://twitter.com/kotlin/status/114345126500075...
# announcements
u
https://twitter.com/kotlin/status/1143451265000759296 Use !is and !in - the counterparts of is and in operators https://pl.kotl.in/S19yPNXpX

https://pbs.twimg.com/media/D8sdPOCXoAAp9WD.pngโ–พ

Twitter
j
๐Ÿค” odd example for
!is
m
@Jonathan Mew You could ask a dog to meow, but he won't do anything ๐Ÿ˜„
๐Ÿ• 3
๐Ÿ˜ผ 2
d
You couldn't ask a dog to meow, there would be a compiler error
๐Ÿ˜‚ 1
j
@Dico well according to the example, you can ask any animal to meow, which is why the example is odd ๐Ÿ™‚
d
No,
meow
could be declared on
Cat
, in which case
animal
is smart casted to
Cat
โž• 1
Because there is ample evidence that
animal
is a
Cat
following the function's first statement
j
. . .
if (animal !is Cat)
๐Ÿ™€
k
Well yeah, if it's you a cat you return and the second line never even runs. So by the time the second line actually happens you can be sure it's a cat.
j
Oh god. I've been reading it as
if (animal !is Cat) return animal.meow()
Thank you for saving me from myself. I'll go get some more sleep now.
๐Ÿ˜† 4
k
Well then you've been reading correctly your code linewrapped for me, great.
s
Braces around if save animals