Menu

1 / 5

Kotlin 2.5 through a Java developer’s eyes. Which account did we just debit?

DEV Community: java·Sergei Cherkasov·2 days ago
#rhOPRR5l
#devtojava#devto#dev#value#long
Long article (2392 words) — no AI summary yet.
Reading 0:00
15s threshold

Hi everyone! My name is Mikhail Polivakha, and I am the technical lead of the open-source project Axelix .

Imagine you’re reviewing a pull request and come across this transfer handler.

fun execute ( transfer : Transfer ) { val ( debit , credit , amount ) = transfer ledger . move ( from = debit , to = credit , amount = amount ) }

Enter fullscreen mode

Exit fullscreen mode

Which account does the money come out of? Judging by the argument names, the one called debit . Now let’s open the DTO.

data class Transfer ( val credit : Long , val debit : Long , val amount : Long )

Enter fullscreen mode

Exit fullscreen mode

Well, there goes the money. Ask this handler to transfer funds from account 10 to account 20, and it’ll debit 20 and credit 10. The named arguments in the call to move just make the code look that much more convincing.

That’s where I want to start with Kotlin 2.5.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.