I do use `when` in my main code. This is just in a...
# announcements
v
I do use
when
in my main code. This is just in a test class. I am just surprised the compiler was understanding that
result
must be a
Post
just because
post
is from a cast. Especially is it is possible for my function to return a
PostGeneration.Error
or a
<http://PostGeneration.Post|PostGeneration.Post>
. I'm going to write a test case which should return a
PostGeneration.Error
and see what happens...
p
if
result
is
Post
then everything will work as expected if
result
is
Error
then class cast exception will be thrown and no statements after cast will be executed so compiler assumption is safe
👆 1
I think in 1.3 version (because of contracts) compiler will assume that
result
is
Post
just after
assertTrue(isPost)
statement.
v
This is all rather cool. I'm going to litter my code with sealed classes now!
🙂 1