Hi, I've just published an article about Kotlin Sm...
# feed
b
Hi, I've just published an article about Kotlin Smart Casting! Feedback is welcome https://brunoaybar.com/kotlin-smart-casting
👍 2
b
nice, but your last example with contracts will fail if you pass a non adult. You still have to check in the
isAdult
function. The contract does not do this on it’s own. So you should return
this@isAdult is Adult
instead of just
true
.
Also this is not really a problem, but why is the
isAdult
function inline? There is no reason for it as far as I can tell, unless this is a requirement for contracts (which is isn’t as far as I know)
s
@ExperimentalContracts
is mind blowing indeed. Did not know it. Thanks Bruno
b
@Burkhard you're very right on both cases! I have updated the article, thank you ✌️
@Sergey Bondari I'm glad you liked it! I actually learned that contracts could be used that way while writing the article 😅 writing content is a great way to learn too :)