[{"data":1,"prerenderedAt":394},["Reactive",2],{"content-query-OKAI55UiV2":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"body":10,"_type":389,"_id":390,"_source":391,"_file":392,"_extension":393},"/talking-computers/statements-expressions/assignments","statements-expressions",false,"","(Re-)Assignments","Variables are data pointers we can update over time.",{"type":11,"children":12,"toc":387},"root",[13,21,43,48,231,236,241,348,381],{"type":14,"tag":15,"props":16,"children":18},"element","h1",{"id":17},"re-assignments",[19],{"type":20,"value":8},"text",{"type":14,"tag":22,"props":23,"children":24},"p",{},[25,27,33,35,41],{"type":20,"value":26},"A variable is only really a variable when it changes, right? As mentioned earlier, variables ",{"type":14,"tag":28,"props":29,"children":30},"em",{},[31],{"type":20,"value":32},"\"point to values\"",{"type":20,"value":34},". And we can change what we point to over time (in Solidity, as long as their general data type ",{"type":14,"tag":36,"props":37,"children":38},"code",{"className":7},[39],{"type":20,"value":40},"string|uint|bool|...",{"type":20,"value":42}," remains the same).",{"type":14,"tag":22,"props":44,"children":45},{},[46],{"type":20,"value":47},"If we look into the constructor of our Marketplace contract, we see the following expressions:",{"type":14,"tag":49,"props":50,"children":54},"pre",{"className":51,"code":52,"language":53,"meta":7,"style":7},"language-solidity shiki shiki-themes github-light github-dark github-light monokai","// We set the owner to the caller of this function,\n// which was Matt & John (LarvaLabs) themselves\nowner = msg.sender;\n\n// We set the total supply to ten thousand punks\ntotalSupply = 10000;\n\n// We set the punks to assign initial owners to the total xsupply (10,000)\npunksRemainingToAssign = totalSupply;\n\n// We set the name to the string `CRYPTOPUNKS` and the symbol to `Ͼ`\nname = \"CRYPTOPUNKS\";\nsymbol = \"Ͼ\";\n","solidity",[55],{"type":14,"tag":36,"props":56,"children":57},{"__ignoreMap":7},[58,70,79,106,110,119,142,146,155,173,177,186,209],{"type":14,"tag":59,"props":60,"children":63},"span",{"class":61,"line":62},"line",1,[64],{"type":14,"tag":59,"props":65,"children":67},{"style":66},"color:#6A737D;--shiki-dark:#6A737D;--shiki-light:#6A737D;--shiki-sepia:#88846F",[68],{"type":20,"value":69},"// We set the owner to the caller of this function,",{"type":14,"tag":59,"props":71,"children":73},{"class":61,"line":72},2,[74],{"type":14,"tag":59,"props":75,"children":76},{"style":66},[77],{"type":20,"value":78},"// which was Matt & John (LarvaLabs) themselves",{"type":14,"tag":59,"props":80,"children":82},{"class":61,"line":81},3,[83,89,95,101],{"type":14,"tag":59,"props":84,"children":86},{"style":85},"color:#24292E;--shiki-dark:#E1E4E8;--shiki-light:#24292E;--shiki-sepia:#F8F8F2",[87],{"type":20,"value":88},"owner ",{"type":14,"tag":59,"props":90,"children":92},{"style":91},"color:#D73A49;--shiki-dark:#F97583;--shiki-light:#D73A49;--shiki-sepia:#F92672",[93],{"type":20,"value":94},"=",{"type":14,"tag":59,"props":96,"children":98},{"style":97},"color:#005CC5;--shiki-dark:#79B8FF;--shiki-light:#005CC5;--shiki-sepia:#FD971F",[99],{"type":20,"value":100}," msg.sender",{"type":14,"tag":59,"props":102,"children":103},{"style":85},[104],{"type":20,"value":105},";",{"type":14,"tag":59,"props":107,"children":109},{"class":61,"line":108},4,[],{"type":14,"tag":59,"props":111,"children":113},{"class":61,"line":112},5,[114],{"type":14,"tag":59,"props":115,"children":116},{"style":66},[117],{"type":20,"value":118},"// We set the total supply to ten thousand punks",{"type":14,"tag":59,"props":120,"children":122},{"class":61,"line":121},6,[123,128,132,138],{"type":14,"tag":59,"props":124,"children":125},{"style":85},[126],{"type":20,"value":127},"totalSupply ",{"type":14,"tag":59,"props":129,"children":130},{"style":91},[131],{"type":20,"value":94},{"type":14,"tag":59,"props":133,"children":135},{"style":134},"color:#005CC5;--shiki-dark:#79B8FF;--shiki-light:#005CC5;--shiki-sepia:#AE81FF",[136],{"type":20,"value":137}," 10000",{"type":14,"tag":59,"props":139,"children":140},{"style":85},[141],{"type":20,"value":105},{"type":14,"tag":59,"props":143,"children":145},{"class":61,"line":144},7,[],{"type":14,"tag":59,"props":147,"children":149},{"class":61,"line":148},8,[150],{"type":14,"tag":59,"props":151,"children":152},{"style":66},[153],{"type":20,"value":154},"// We set the punks to assign initial owners to the total xsupply (10,000)",{"type":14,"tag":59,"props":156,"children":158},{"class":61,"line":157},9,[159,164,168],{"type":14,"tag":59,"props":160,"children":161},{"style":85},[162],{"type":20,"value":163},"punksRemainingToAssign ",{"type":14,"tag":59,"props":165,"children":166},{"style":91},[167],{"type":20,"value":94},{"type":14,"tag":59,"props":169,"children":170},{"style":85},[171],{"type":20,"value":172}," totalSupply;",{"type":14,"tag":59,"props":174,"children":176},{"class":61,"line":175},10,[],{"type":14,"tag":59,"props":178,"children":180},{"class":61,"line":179},11,[181],{"type":14,"tag":59,"props":182,"children":183},{"style":66},[184],{"type":20,"value":185},"// We set the name to the string `CRYPTOPUNKS` and the symbol to `Ͼ`",{"type":14,"tag":59,"props":187,"children":189},{"class":61,"line":188},12,[190,195,199,205],{"type":14,"tag":59,"props":191,"children":192},{"style":85},[193],{"type":20,"value":194},"name ",{"type":14,"tag":59,"props":196,"children":197},{"style":91},[198],{"type":20,"value":94},{"type":14,"tag":59,"props":200,"children":202},{"style":201},"color:#032F62;--shiki-dark:#9ECBFF;--shiki-light:#032F62;--shiki-sepia:#E6DB74",[203],{"type":20,"value":204}," \"CRYPTOPUNKS\"",{"type":14,"tag":59,"props":206,"children":207},{"style":85},[208],{"type":20,"value":105},{"type":14,"tag":59,"props":210,"children":212},{"class":61,"line":211},13,[213,218,222,227],{"type":14,"tag":59,"props":214,"children":215},{"style":85},[216],{"type":20,"value":217},"symbol ",{"type":14,"tag":59,"props":219,"children":220},{"style":91},[221],{"type":20,"value":94},{"type":14,"tag":59,"props":223,"children":224},{"style":201},[225],{"type":20,"value":226}," \"Ͼ\"",{"type":14,"tag":59,"props":228,"children":229},{"style":85},[230],{"type":20,"value":105},{"type":14,"tag":22,"props":232,"children":233},{},[234],{"type":20,"value":235},"All these assignments above either initially set or change the pointer of our variables to a new value.",{"type":14,"tag":22,"props":237,"children":238},{},[239],{"type":20,"value":240},"Check out line 17 and 95:",{"type":14,"tag":49,"props":242,"children":244},{"className":51,"code":243,"language":53,"meta":7,"style":7},"// Line 17\nbool public allPunksAssigned = false;\n\nfunction allInitialOwnersAssigned() {\n  // Line 95\n  allPunksAssigned = true;\n}\n",[245],{"type":14,"tag":36,"props":246,"children":247},{"__ignoreMap":7},[248,256,289,292,311,319,340],{"type":14,"tag":59,"props":249,"children":250},{"class":61,"line":62},[251],{"type":14,"tag":59,"props":252,"children":253},{"style":66},[254],{"type":20,"value":255},"// Line 17",{"type":14,"tag":59,"props":257,"children":258},{"class":61,"line":72},[259,265,271,276,280,285],{"type":14,"tag":59,"props":260,"children":262},{"style":261},"color:#005CC5;--shiki-dark:#79B8FF;--shiki-light:#005CC5;--shiki-sepia:#66D9EF;font-style:inherit;--shiki-dark-font-style:inherit;--shiki-light-font-style:inherit;--shiki-sepia-font-style:italic",[263],{"type":20,"value":264},"bool",{"type":14,"tag":59,"props":266,"children":268},{"style":267},"color:#D73A49;--shiki-dark:#F97583;--shiki-light:#D73A49;--shiki-sepia:#66D9EF;font-style:inherit;--shiki-dark-font-style:inherit;--shiki-light-font-style:inherit;--shiki-sepia-font-style:italic",[269],{"type":20,"value":270}," public",{"type":14,"tag":59,"props":272,"children":273},{"style":85},[274],{"type":20,"value":275}," allPunksAssigned ",{"type":14,"tag":59,"props":277,"children":278},{"style":91},[279],{"type":20,"value":94},{"type":14,"tag":59,"props":281,"children":282},{"style":134},[283],{"type":20,"value":284}," false",{"type":14,"tag":59,"props":286,"children":287},{"style":85},[288],{"type":20,"value":105},{"type":14,"tag":59,"props":290,"children":291},{"class":61,"line":81},[],{"type":14,"tag":59,"props":293,"children":294},{"class":61,"line":108},[295,300,306],{"type":14,"tag":59,"props":296,"children":297},{"style":267},[298],{"type":20,"value":299},"function",{"type":14,"tag":59,"props":301,"children":303},{"style":302},"color:#6F42C1;--shiki-dark:#B392F0;--shiki-light:#6F42C1;--shiki-sepia:#A6E22E",[304],{"type":20,"value":305}," allInitialOwnersAssigned",{"type":14,"tag":59,"props":307,"children":308},{"style":85},[309],{"type":20,"value":310},"() {",{"type":14,"tag":59,"props":312,"children":313},{"class":61,"line":112},[314],{"type":14,"tag":59,"props":315,"children":316},{"style":66},[317],{"type":20,"value":318},"  // Line 95",{"type":14,"tag":59,"props":320,"children":321},{"class":61,"line":121},[322,327,331,336],{"type":14,"tag":59,"props":323,"children":324},{"style":85},[325],{"type":20,"value":326},"  allPunksAssigned ",{"type":14,"tag":59,"props":328,"children":329},{"style":91},[330],{"type":20,"value":94},{"type":14,"tag":59,"props":332,"children":333},{"style":134},[334],{"type":20,"value":335}," true",{"type":14,"tag":59,"props":337,"children":338},{"style":85},[339],{"type":20,"value":105},{"type":14,"tag":59,"props":341,"children":342},{"class":61,"line":144},[343],{"type":14,"tag":59,"props":344,"children":345},{"style":85},[346],{"type":20,"value":347},"}",{"type":14,"tag":22,"props":349,"children":350},{},[351,353,358,360,365,367,372,374,379],{"type":20,"value":352},"We initially instantiate ",{"type":14,"tag":36,"props":354,"children":355},{"className":7},[356],{"type":20,"value":357},"allPunksAssigned",{"type":20,"value":359}," with ",{"type":14,"tag":36,"props":361,"children":362},{"className":7},[363],{"type":20,"value":364},"false",{"type":20,"value":366},", and change it to ",{"type":14,"tag":36,"props":368,"children":369},{"className":7},[370],{"type":20,"value":371},"true",{"type":20,"value":373}," in the ",{"type":14,"tag":36,"props":375,"children":376},{"className":7},[377],{"type":20,"value":378},"allIninitialOwnersAssigned()",{"type":20,"value":380}," function.",{"type":14,"tag":382,"props":383,"children":384},"style",{},[385],{"type":20,"value":386},"html.dark .shiki span {color: var(--shiki-dark) !important;background: var(--shiki-dark-bg) !important;font-style: var(--shiki-dark-font-style) !important;font-weight: var(--shiki-dark-font-weight) !important;text-decoration: var(--shiki-dark-text-decoration) !important;}html.light .shiki span {color: var(--shiki-light) !important;background: var(--shiki-light-bg) !important;font-style: var(--shiki-light-font-style) !important;font-weight: var(--shiki-light-font-weight) !important;text-decoration: var(--shiki-light-text-decoration) !important;}html.sepia .shiki span {color: var(--shiki-sepia) !important;background: var(--shiki-sepia-bg) !important;font-style: var(--shiki-sepia-font-style) !important;font-weight: var(--shiki-sepia-font-weight) !important;text-decoration: var(--shiki-sepia-text-decoration) !important;}",{"title":7,"searchDepth":72,"depth":72,"links":388},[],"markdown","content:4.talking-computers:4.statements-expressions:2.assignments.md","content","4.talking-computers/4.statements-expressions/2.assignments.md","md",1772893314978]