Rust

match (Rust)

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

match e krahason një vlerë me disa modele dhe ekzekuton krahun e duhur. Kompajleri të detyron t'i mbulosh të gjitha rastet — po harrove një, s'kompajlohet.

EnglishEN

match compares a value against several patterns and runs the matching arm. The compiler forces you to cover every case — forget one and it won't compile.

Si ta mendosh

Si sportelet në postë: çdo kërkesë ka sportelin e vet, dhe asnjë s'mbetet pa vend.

Lexoje në anglisht

Like counters at the post office: every request has its counter, and none is left without one.

Shembull kodirust

let mesazhi = match nota {
    5 => "Shkëlqyeshëm",
    2..=4 => "Kaloi",
    _ => "Ngeli",
};

Terma të lidhur