This message was deleted.
# getting-started
s
This message was deleted.
c
val (hello, world) = "hello" to "world"
. The
to
function makes a
Pair
, which can be destructured
c
This is probably a bad idea for performance, at least until pair gets rewritten as a
value class
(if it ever does)
n
performance impact is likely to be very minimal, especially if the JVM decides to allocate the Pair on the stack
c
Unless you’re building something that is very performance-sensitive (database engine, HTTP client, UI toolkit, low-level stuff like that, or data processing on very large inputs), it’s usually better to optimize code for readability rather than doing a bunch of “micro-optimizations”. In typical application code, you’ll spend more time fixing bugs in logic than you will trying to make it run faster, so it’s better to set yourself up for readability and maintainability instead of using uglier code that is more performant
☝️ 1
s
agree with @Casey Brooks — write for clarity than syntax cleverness
n
a lot of questions I see on Getting Started is about contorting Kotlin into doing things in as few lines of code as possible, which isn't actually what Kotlin is about. in this case you're probably better off with two assignments, unless the thing on the right-hand side is already a single data class or something
s
I’m seeing lot of issues within mature codebases- ppl electing to be fancy and ensuing havoc
n
or maybe "how do I do this Ruby/Python pattern in Kotlin" :)
💯 2