Explain Kotlin code

Paste Kotlin and Vibe explains where null can turn up, what a data class writes for you and where an extension function comes from.

Parcel.kt

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe12 lines selected

Press Explain it for the sample, or paste your own code first.

What this Kotlin sample shows

null safety
note is a String?, so it may be null, and it is unless you pass one. note?.trim() calls trim only when there is a note, and ?: "no note" fills in when there isn't. Write note.trim() and the compiler stops: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?.
extensions
fun Parcel.label() and fun Parcel.withExtra() add functions to Parcel from outside the class, so packingLabels can call it.label() as if it were a method. Inside them, code, grams, note and copy belong to the parcel they were called on.
data classes
data class writes equals, copy and destructuring for the three properties. withExtra(25) returns a 525 g copy and leaves the 500 g original as it was, original == original.copy() is true, and val (code, grams, note) = original gives BOX, 500 and null.

Good to know

  • packingLabels turns a 500 g BOX without a note and a 100 g BAG whose note is fragile with two spaces on each side into BOX: 500 g (no note) and BAG: 100 g (fragile).
  • withExtra changes only grams: the copy keeps the original's code and note, and the two parcels are not equal.
  • An empty list of parcels gives an empty list of labels.

Watch out: ?: only steps in for null. A note of three spaces trims to an empty string, which isn't null, so a 20 g ENV parcel with that note gets the label ENV: 20 g (). note?.trim()?.ifBlank { null } ?: "no note" gives no note for it.

Explain Kotlin code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

No install warning? Use Unvibe in your browser

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done.
    macOS dialog: Unvibe Not Opened, with Done and Move to Trash
    Real screen, macOS 15
  3. System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open