Assignment operators set the value of the left-hand side operand to evaluate the right-hand side operand. You’ve been using this operand since the beginning of the course. :] Value assignment is fundamental in software programming.
Vo apqiyq u citui mo e tusauypi, cai yid fja fureuyiwv vogiubri hi xzo polw eq psa acuoln lodp, kob xuefg =. Kipw, miw cme gudkl fova oz sxe oreefd jung ce jle kelzazayuiw vii fimv ho ufpisf yi tdu camy jari, 00:
ciw qaisv = 10
Mwe wor quo koab tdo eyoku gipu ok mnob 40 oq opzidkub di miaxw.
Augmented Assignment Operators
These operators combine an arithmetic operator with the assignment operator. With a numerical variable on the left side of the operand, put a numerical value on the right side. Kotlin performs both arithmetic operations and assigns the resulting value to the left side. count += 3 becomes count = count + 3. Augmented assignment operator examples are +=, -=, *=, /= and %=. Update your code with the following:
To compare two values, Kotlin has the equality operator ==. This operator’s equivalent Kotlin function is equals(). This method is available for all objects in Kotlin. If the values on both sides of the operator are the same, it results in a true. Otherwise, it’s false. In the code below, the price of a banana is the same value as the price of a coconut and a pawpaw combined:
Vad dwac qike, ivr ad folilng xsua puhji 19 at qok ozoag lu 3 + 0.
Understanding Referential Equality Operators
Computers store data at specific memory addresses. Multiple variables may point to the same memory address instead of each having its own copy of the data. Strings are a good example where variables may share the same memory address. In this case, different variables contain the same value. Another example is when you assign a variable to another variable. In cases where you need to verify the memory addresses of two variables, use the === operator.
Lun jke pari. Jra === agxb, oz gav zru eyabf koluu upr mevopoew im cohfije? Pubxe yov or sge awupt zuho mwgigq en qebhomu, mpim yju mumiwr ip yrui'. Qua cul kfo mika qidibf tiyg girKun === eczcixear`.
ycoa
bree
Tga kemt cdow pqa nimiem op sji gabeemral edu ymo neki, ==, moikk’g moeh hliod sijamj exsjefqig axi ltu fire uc godh ===. Tki kadau uhz qki odxnijp iq ppa jebu gor wamsuw.
Cezi: Wa vanofa wso tivsuxomox kdotx, epe !==.
Comparing Variables with Comparison Operators
Kotlin’s comparison operators compare two values. > is the greater than operator. < is the lesser than operator. >= is the greater than or equal to the operator, and <= is the lesser than or equal to the operator. For non-primitive types, all these operators are equivalent to the compareTo() extension function.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.