Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

It’s All the Same! 96 of 100 Days of…

  • March 25, 2021March 26, 2021
  • by Richard Clarke

I went to submit my solution on codewars and found something pretty cool

Recently I talked about the conclusion to the Keep Hydrated codingkata on codewars. I built a fully functioning command line app, but I still needed to upload my solution.

For more on this, watch the video at the bottom of the page. You can find the source code for the Kotlin version here, and the Java version here.

When I went to the codewars website, I noticed something familiar about the function provided.

This one had a return type in the function header!

I haven’t covered this yet, but I knew exactly what I was looking at. The codingkata provided an empty function which returned a value of type Int. I updated my solution using this new information.

In my version, I created a function which returned a Double instead. After this update, I wanted to see a side by side comparison with a Java program. My next move was to recreate this same program in Java

Doing this in Java helped me better analyze Kotlin syntax for functions. I even noticed a pattern with how colons are used in Kotlin. Typically there’s a variable or something which returns a value, followed by a colon, and the datatype. The format usually follows:

Now I know how to set return types for functions in Kotlin. I’ve said it before, coding challenges are a great way to learn about a language. Even the simplest ones can take you far.

Join the mailing list to see updates like this every week!
Coding Fanatic

Related

Five Things to Avoid When Socializing Online – Road 2 Pro 11
Forget About Coding Tests! Road 2 Pro 12
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode Android Android Development AndroidDev development double int Java kotlin software software development

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress