Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

please find the error and submit

AnishChaudhary
AnishChaudhary

type checks and automatic casts
i was practicing this and couldn't solve this please solve

1 year ago

Voters

Comments

TopNew
1
AmoghTheCool
AmoghTheCool

the bug here is that you are not calling the functions in the main function as you should be doing. An error-free version of this would be:

fun getStringlength(obj:Any):Int?{ if (obj is String && obj.length>0){ return obj.length } return null } fun main(){ fun printLength(obj:Any){ println("Getting the length of '$obj'.Result: ${getStringlength(obj) ?:"Error: The object is not a string"} ") } printLength("Incomprehensibilities") printLength("") printLength(1000) }
1 year ago
1
AmoghTheCool
AmoghTheCool

Select this as the correct answer if it helps!

1 year ago
1
AnishChaudhary
AnishChaudhary

@AmoghTheCool
bro do you know swing, help me to embed images
check my repl
repl name : creating a simple gui part 2

1 year ago
1
AmoghTheCool
AmoghTheCool

@AnishChaudhary
sorry, no i don't. I have decent experience in Kotlin/Android, tho. I don't do java.

this is a good video EXACTLY fitting your needs.

1 year ago
Load more