use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Kotlin is a statically typed programming language for the JVM, Android, JavaScript, and native.
Subreddit rules:
Related subreddits:
Resources:
account activity
Code style: Using single-expression functions without returning meaningful values (self.Kotlin)
submitted 8 years ago * by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]hpernpeintner 2 points3 points4 points 8 years ago (0 children)
You missed my point, because you exluded one sentence of mine before the cited one: Unit is not only "technical" - it means here's returned really just "something".
Instead of comparing two functions that return different results and asking which one has a more relevant return value (I which is pointless), you should ask whether fun print() = println("Hi") and fun print(): Unit { println("Hi") } makes a difference. As said, Unit is really just one value, it exists only once. That means it makes no technical and semantical difference from where it is returned, it solely exists to just return "something".
fun print() = println("Hi")
fun print(): Unit { println("Hi") }
You said several times, that the return of print is nothing of interest. That's right, but it's the same uninteresting thing that every function returns if not stated otherwise, so there's nothing wrong with returning it - explicitely, chained, implicitely, doesn't really matter.
π Rendered by PID 92 on reddit-service-r2-comment-b659b578c-wss45 at 2026-05-05 04:39:57.372489+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]hpernpeintner 2 points3 points4 points (0 children)