Vai al contenuto principale
ProdottiStrumenti desktopTASTECADVisualizzazione disegniTASTEFILESGestione fileTASTEFTPTrasferimento fileTASTESSHSpazio di lavoro remotoTASTEZIPCompressione ed estrazioneTASTEWINMGestione fileStrumenti per sviluppatoriTASTECODEAmbiente di sviluppo integrato per RustTASTESTUDIOAmbiente integrato di sviluppo e testTASTEETLIntegrazione dati (ETL)ServerTASTEREMOTEServer di desktop remotoTASTEGEOServer geospazialeTASTEMAILSpazio di lavoro emailInvestimentiTASTESTOCKApp desktop di trading automatico azionarioIniziaDownloadDocumentazioneAcquistaTutti i prodotti
Marketplace
Notizie
TecnologiaNotizieNotizie di sviluppo di oggiDocumentazioneLinguaggi di programmazioneRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFramework frontend webNext.jsReactVue.js · NuxtSvelteKitAngularFramework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFramework per app e desktopTauriFlutterReact NativeElectronAlgoritmiBasi degli algoritmiAlgoritmi fondamentaliAlgoritmi avanzatiAlgoritmi pratici
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrinaGuida alla community
CollaboraTrasferimento tecnicoRealizzazione del sito webRealizzazione di app desktopPipeline di rilascio e pagamentoPartner commercialeContatti
ServiziDesktop remotoPacchetti di installazione su misura
TASTEDEV
Prodotti

Strumenti desktop

TASTECADApri con leggerezza anche i disegni più complessiTASTEFILESSolo i file che servono, alla massima velocitàTASTEFTPLa via più ordinata per i tuoi fileTASTESSHUn legame più solido tra te e i tuoi serverTASTEZIPComprimi più veloce, estrai più sicuroTASTEWINMUn file manager a due pannelli pensato per la tastiera

Strumenti per sviluppatori

TASTECODEModifica, compila, esegui il debug e testa app Rust in un'unica finestraTASTESTUDIODalla modifica ai test remoti e alle correzioni IA approvateTASTEETLSposta i dati guardando i valori

Server

TASTEREMOTEUn desktop remoto che gira sul tuo serverTASTEGEOUn server geospaziale compatibile con GeoServer, ricostruito in RustTASTEMAILRiprendi il controllo della tua posta

Investimenti

TASTESTOCKTrading automatico azionario secondo le regole che decidi tu: quando e che cosa

Inizia

DownloadUltime versioni di ogni prodottoDocsCome usare ogni prodottoAcquistaAbbonamenti e licenze perpetueTutti i prodottiTutti i prodotti a colpo d’occhio
Tutti i prodotti
MarketplaceNotizie
Tecnologia

Notizie

Notizie di sviluppo di oggiAnnunci ufficiali su linguaggi, framework, GitHub e IADocumentazioneGuide a linguaggi, framework e algoritmi

Linguaggi di programmazione

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Framework

Framework frontend webNext.jsReactVue.js · NuxtSvelteKitAngular
Framework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Framework per app e desktopTauriFlutterReact NativeElectron

Algoritmi

Basi degli algoritmiAnalisi della complessità · Ordinamento · Ricerca · Strutture dati di base · Alberi e heapAlgoritmi fondamentaliVisita dei grafi · Cammini minimi e alberi ricoprenti · Programmazione dinamica · Algoritmi greedy · Divide et impera · BacktrackingAlgoritmi avanzatiAlgoritmi sulle stringhe · Matematica e teoria dei numeri · Manipolazione dei bit · Alberi di segmenti · Union-FindAlgoritmi praticiStrategia per colloqui di programmazione · Cache LRU · Rate limiting · Hashing consistente
Tutta la documentazione di sviluppo
Community
ProgettiScopri sviluppatori e lavoriLog di sviluppoDecisioni e lezioni appresePromptIstruzioni riutilizzabiliProblemi degli strumenti di IAProblemi e alternative di Claude, Codex, GeminiVetrinaRisultati completatiGuida alla communityCome sviluppiamo in modo aperto
Collabora
Trasferimento tecnicoApp native in Rust ed eguiRealizzazione del sito web10 lingue, account, documentazione e downloadRealizzazione di app desktopRust ed egui, senza WebViewPipeline di rilascio e pagamentoFirma, MSI, deb, rpm, AppImage, hashPartner commercialeConsigliaci e ricevi il 30%ContattiSviluppo, partnership e investimenti
Servizi
Desktop remotoRaggiungi il tuo computer dal browserPacchetti di installazione su misuraSolo il necessario, impostazioni precaricate
Acquista
IT
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Accedi
Accedi
TASTEDEV

Dai piccoli strumenti a uno sviluppo migliore.

support@tastedev.netSostieni TASTEDEV
ProdottiGamma di prodottiAcquistaDocsDownloadMarketplaceAssistenza
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrina
NormeChi siamoInformativa sulla privacyTermini di servizioCondizioni di abbonamentoRimborsiLinee guida della community
AccountAccediRegistrati
Visitatori
Oggi
Ieri
Visualizzazioni totali
Società
GXSOFT
Rappresentante
CHOI YOUNG GU
Numero di registrazione
853-44-00368
Indirizzo
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefono
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsabile privacy
CHOI YOUNG GU

© 2026 TASTEDEVLe informazioni sui prodotti si basano su fonti di sviluppo verificate.Rilasciato · in miglioramento

Documentazione di Kotlin
Kotlin
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
Discussioni

Guida a Kotlin · 6/6

Key Concepts

Per ora questo capitolo è disponibile solo in inglese.

The last chapter covers four ideas that make Kotlin feel like Kotlin: null safety, extension functions, lambdas, and coroutines.

Null safety

A String can never hold null; to allow it, write String?. Members of a nullable value cannot be called directly, which turns most NullPointerExceptions into compile errors.

fun main() {
    var nickname: String? = null      // nullable thanks to ?
    // println(nickname.length)       // compile error

    println(nickname?.length)         // null: safe call
    println(nickname?.length ?: 0)    // 0: Elvis operator supplies a default
    nickname = "Kotlin"
    println(nickname!!.length)        // 6: throws if null

    nickname?.let { println("Nickname is $it") }   // runs only when not null
}
OperatorMeaning
?.call if not null, otherwise the result is null
?:use the right side when the left is null
!!assert not null, throw otherwise
as?safe cast that returns null on failure

Use !! sparingly. After a null check or an is check, the compiler treats the variable as the narrower type: a smart cast.

fun lengthOf(value: Any?): Int {
    if (value == null) return 0
    if (value is String) return value.length   // smart cast to String
    if (value is List<*>) return value.size
    return value.toString().length
}

fun findUser(id: Int): String? = if (id == 1) "admin" else null

fun requireUser(id: Int): String =
    findUser(id) ?: throw IllegalArgumentException("Unknown user: $id")

Smart casts fail when the value might change after the check, as with a mutable var property. Copy it into a local val first.

Extension functions

Extensions add functions to a class without editing or subclassing it. Put the receiver type before the name; inside, the receiver is this.

fun String.initials(): String =
    split(" ").filter { it.isNotBlank() }.joinToString("") { it.first().uppercase() }

val <T> List<T>.secondOrNull: T?
    get() = if (size >= 2) this[1] else null

fun main() {
    println("kotlin is fun".initials())     // KIF
    println(listOf(1, 2, 3).secondOrNull)   // 2
}

Extensions do not modify the class. They compile to static functions taking the receiver as the first argument, are resolved from the static type at compile time, and cannot see private members. Much of the standard library, including filter, and , is built this way.

Domande su questo capitolo?
Capitolo precedenteErrors and Testing
map
let

Lambdas and higher-order functions

A higher-order function takes functions as parameters or returns one. Function types look like (Int) -> Int, lambdas are written in braces, and a lambda with one parameter can refer to it as it.

fun applyTwice(x: Int, f: (Int) -> Int): Int = f(f(x))

fun isEven(n: Int) = n % 2 == 0

fun main() {
    val double: (Int) -> Int = { it * 2 }
    val add = { a: Int, b: Int -> a + b }

    println(applyTwice(3, double))          // 12
    println(applyTwice(3) { it + 10 })      // 23: trailing lambda
    println(add(2, 5))                      // 7
    println((1..6).filter(::isEven))        // [2, 4, 6]: function reference

    val words = listOf("apple", "kiwi", "banana", "fig")
    val result = words
        .filter { it.length > 3 }
        .sortedBy { it.length }
        .map { it.uppercase() }
    println(result)                         // [KIWI, APPLE, BANANA]
}

When the last parameter is a function, the lambda can move outside the parentheses, which is why repeat(3) { ... } or Gradle's dependencies { ... } look like built-in syntax. An inline function is copied into each call site, avoiding lambda allocations.

Coroutine basics

Coroutines are lightweight tasks that suspend without blocking a thread. The language provides the suspend keyword; launch, async and friends come from the kotlinx-coroutines-core library.

import kotlinx.coroutines.*

suspend fun fetchPrice(item: String): Int {
    delay(300)              // waits without blocking the thread
    return item.length * 1000
}

fun main() = runBlocking {
    val job = launch {
        delay(100)
        println("launch: work with no result")
    }

    val apple = async { fetchPrice("apple") }
    val melon = async { fetchPrice("melon") }
    println("Total: ${apple.await() + melon.await()}")   // both run concurrently

    job.join()
}

A suspend function can only be called from a coroutine or another suspend function. launch returns a Job for work without a result; async returns a Deferred whose value you read with await(). runBlocking bridges regular and coroutine code and belongs only in main or tests.

Under structured concurrency, children run inside a parent scope that waits for them all, and a failure cancels the siblings. Move blocking I/O onto a suitable thread pool with withContext(Dispatchers.IO).

suspend fun readConfig(path: String): String = withContext(Dispatchers.IO) {
    java.io.File(path).readText()
}

suspend fun loadAll(paths: List<String>): List<String> = coroutineScope {
    paths.map { async { readConfig(it) } }.awaitAll()
}

Summary

  • T and T? are different types; handle null with ?., ?: and smart casts, and keep !! rare.
  • Extension functions add behavior without changing a class and are resolved at compile time.
  • Lambdas, higher-order functions and trailing-lambda syntax underpin the standard library and Kotlin DSLs.
  • Coroutines use suspend, launch and async to make asynchronous code read sequentially.

Further reading in the official docs:

  • Kotlin documentation
  • Null safety
  • Extensions
  • Higher-order functions and lambdas
  • Coroutines guide
  • Kotlin Koans exercises

0 commenti

Commenti principaliPrima i più recenti

Accedi · Accedi per lasciare un commento.