A mutable object hloov tau tom qab nws tsim, thiab ib yam khoom hloov tsis tau. Uas tau hais tias, yog tias koj tab tom txiav txim siab koj tus kheej hauv chav kawm, koj tuaj yeem ua rau nws cov khoom hloov tsis tau los ntawm kev ua txhua qhov kawg thiab ntiag tug. … Los yog, koj tuaj yeem hloov txoj hlua mus rau ib qho array ntawm cov cim, uas yuav hloov tau.
Dab tsi yog qhov txawv ntawm hom ntaub ntawv hloov pauv thiab hloov pauv tsis tau?
Yog tus nqi hloov tau, qhov khoom hu ua mutable, hos yog tus nqi hloov tsis tau, qhov khoom hu ua hloov tsis tau.
Dab tsi yog qhov hloov pauv thiab hloov tsis tau muab piv txwv?
Yooj yim tso, cov khoom hloov pauv tuaj yeem hloov pauv tom qab nws tsim, thiab cov khoom hloov pauv tsis tuaj yeem ua tsis tau. Cov khoom ntawm built-in hom xws li (int, ntab, bool, str, tuple, unicode) yog hloov tsis tau. Cov khoom ntawm cov khoom tsim hauv xws li (cov npe, teeb tsa, lus txiav txim) yog qhov hloov pauv tauCov chav kawm kev cai feem ntau hloov tau.
Dab tsi yog qhov sib txawv ntawm kev hloov pauv thiab hloov tsis tau hauv Swift?
Mutable txhais tau tias tus nqi tuaj yeem hloov pauv thaum pib teeb tsa (los ntawm kev pib), qhov immutable txhais tau tias tus nqi hloov tsis tau.
Koj nkag siab dab tsi los ntawm cov khoom sib hloov thiab hloov tsis tau?
Cov khoom uas nws tus nqi tuaj yeem hloov pauv tau hais tias hloov pauv tau. Cov khoom uas nws tus nqi hloov tsis tau thaum lawv raug tsim los yog hu ua hloov tsis tau.