Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
retnikt67745ySets index (slash + i incremented) of Routes to (an anonymous function taking in an unused parameter and returning a LevelPage of i) if it is not null
-
Kotlin has normal if else in place of ternary operator, which is actually more readable.
-
inaba45895y@kescherRant * just as readable and it certainly doesn't have a normal if/else since a normal if/else wouldn't be expressions lmao
-
@kescherRant you are saying that
If(someVal)
othervar = 12;
Else
othervar = 294637;
Is more readable then
othervar = someVal ? 12 : 294637;
??? -
Root797755y@Codex404 Please, for the love of readibility, enclose your ternaries in parenthesies.
@kescherRant Yes, but much more verbose. I loathe needing to write multiple keywords and/or use semicolons for something that should really be a single line. -
If you think this is bad, check out Haskell lol
Eg.
@highlight
instance (Applicative f, Applicative g) => Applicative (Compose f g) where
pure x = Compose $ (pure . pure) x
(<*>) (Compose f) <*> (Compose a) = Compose $ ((<*>) <$> f) <*> a
Edit: ignore mistyped (<*>) behind (Compose f) -
eeee31225y@inaba @Codex404
Kotlin if-else can be both statements and expressions.
You wouldn't write two assignments in both the branches, that's a style violation in Kotlin. IntelliJ even warns you about this and suggests the expression instead. Two examples of if-expressions:
@highlight
// Oneliner
val x = if (condition) y else z
// Multiline
val x = if (condition) {
sideEffectA()
y
} else {
sideEffectB()
z
} -
@eeee single line if statements are the new worst. I always change it to a multi-line one the moment I see one.
-
@rostopira if you ever post something in the wrong category, just give @dfox a mention. He'll usually fix it up for you
Related Rants
Kotlin: I don't have ternary operator, it's bad for readability
Swift: I removed ++ and --, cause they are old fashioned
Dart: *screams*
joke/meme
joke
swift
kotlin
dart