https://kotlinlang.org logo
#feed
Title
# feed
b

bruno.aybar

06/02/2019, 10:35 PM
Hi, I've just published an article about Kotlin Smart Casting! Feedback is welcome https://brunoaybar.com/kotlin-smart-casting
👍 2
b

Burkhard

06/02/2019, 10:45 PM
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

Sergey Bondari

06/02/2019, 11:15 PM
@ExperimentalContracts
is mind blowing indeed. Did not know it. Thanks Bruno
b

bruno.aybar

06/03/2019, 3:03 PM
@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 :)
3 Views