[{"data":1,"prerenderedAt":1277},["ShallowReactive",2],{"navigation_docs":3,"-features-lambda":198,"-features-lambda-surround":1272},[4,30,81,118,147,171,184],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting Started",false,"/getting-started","1.getting-started",[10,15,20,25],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","/getting-started/introduction","1.getting-started/2.introduction","i-lucide-house",{"title":16,"path":17,"stem":18,"icon":19},"Installation","/getting-started/installation","1.getting-started/3.installation","i-lucide-download",{"title":21,"path":22,"stem":23,"icon":24},"Quick start","/getting-started/quickstart","1.getting-started/4.quickstart","i-lucide-code-xml",{"title":26,"path":27,"stem":28,"icon":29},"Troubleshooting","/getting-started/troubleshooting","1.getting-started/5.troubleshooting","i-lucide-wrench",{"title":31,"icon":6,"path":32,"stem":33,"children":34,"page":6},"Core Features","/core-features","2.core-features",[35,39,43,48,52,56,60,64,68,73,77],{"title":36,"path":37,"stem":38,"icon":24},"Main function","/core-features/main-function","2.core-features/1.main-function",{"title":40,"path":41,"stem":42,"icon":24},"Variables","/core-features/variables","2.core-features/2.variables",{"title":44,"path":45,"stem":46,"icon":47},"Comment","/core-features/comment","2.core-features/3.comment","i-lucide-hash",{"title":49,"path":50,"stem":51,"icon":24},"Conditionals","/core-features/conditionals","2.core-features/4.conditionals",{"title":53,"path":54,"stem":55,"icon":24},"Loops","/core-features/loops","2.core-features/5.loops",{"title":57,"path":58,"stem":59,"icon":24},"Functions","/core-features/functions","2.core-features/6.functions",{"title":61,"path":62,"stem":63,"icon":24},"Pointers","/core-features/pointers","2.core-features/7.pointers",{"title":65,"path":66,"stem":67,"icon":24},"Data types","/core-features/datatypes","2.core-features/8.datatypes",{"title":69,"path":70,"stem":71,"icon":72},"Operators","/core-features/operators","2.core-features/9.operators","i-lucide-percent",{"title":74,"path":75,"stem":76,"icon":24},"Literals","/core-features/a.literals","2.core-features/a.literals",{"title":78,"path":79,"stem":80,"icon":24},"Keywords","/core-features/b.keywords","2.core-features/b.keywords",{"title":82,"icon":6,"path":83,"stem":84,"children":85,"page":6},"Features","/features","3.features",[86,90,94,98,102,106,110,114],{"title":87,"path":88,"stem":89,"icon":24},"Const","/features/const","3.features/1.const",{"title":91,"path":92,"stem":93,"icon":24},"Define","/features/define","3.features/2.define",{"title":95,"path":96,"stem":97,"icon":24},"Enum","/features/enum","3.features/3.enum",{"title":99,"path":100,"stem":101,"icon":24},"Union","/features/union","3.features/4.union",{"title":103,"path":104,"stem":105,"icon":24},"Overloading","/features/overloading","3.features/5.overloading",{"title":107,"path":108,"stem":109,"icon":24},"Lambda","/features/lambda","3.features/6.lambda",{"title":111,"path":112,"stem":113,"icon":24},"Callback","/features/callback","3.features/7.callback",{"title":115,"path":116,"stem":117,"icon":24},"Auto","/features/auto","3.features/8.auto",{"title":119,"icon":6,"path":120,"stem":121,"children":122,"page":6},"Advance Features","/advance","4.advance",[123,127,131,135,139,143],{"title":124,"path":125,"stem":126,"icon":24},"Generic Type","/advance/generic-type","4.advance/1.generic-type",{"title":128,"path":129,"stem":130,"icon":24},"Errors","/advance/error","4.advance/2.error",{"title":132,"path":133,"stem":134,"icon":24},"Annotation","/advance/annotation","4.advance/3.annotation",{"title":136,"path":137,"stem":138,"icon":24},"Variadic Function","/advance/variadic-func","4.advance/4.variadic-func",{"title":140,"path":141,"stem":142,"icon":24},"Module","/advance/module-interface","4.advance/5.module-interface",{"title":144,"path":145,"stem":146,"icon":24},"Operator Overloading","/advance/operator-overloading","4.advance/6.operator-overloading",{"title":148,"icon":6,"path":149,"stem":150,"children":151,"page":6},"Struct","/struct","5.struct",[152,155,159,163,167],{"title":148,"path":153,"stem":154,"icon":24},"/struct/struct","5.struct/1.struct",{"title":156,"path":157,"stem":158,"icon":24},"Methods","/struct/methods","5.struct/2.methods",{"title":160,"path":161,"stem":162,"icon":24},"Init/Deinit","/struct/init-deinit","5.struct/3.init-deinit",{"title":164,"path":165,"stem":166,"icon":24},"Encapsulation","/struct/encapsulation","5.struct/4.encapsulation",{"title":168,"path":169,"stem":170,"icon":24},"Static","/struct/static","5.struct/5.static",{"title":172,"icon":6,"path":173,"stem":174,"children":175,"page":6},"Data Structures","/data-structure","6.data-structure",[176,180],{"title":177,"path":178,"stem":179,"icon":24},"Array","/data-structure/array","6.data-structure/array",{"title":181,"path":182,"stem":183,"icon":24},"Structural Type","/data-structure/strutural-type","6.data-structure/strutural-type",{"title":185,"icon":6,"path":186,"stem":187,"children":188,"page":6},"Standard Libraries","/stdlib","7.stdlib",[189,194],{"title":190,"path":191,"stem":192,"icon":193},"stdlib","/stdlib/stdlib","7.stdlib/stdlib","i-lucide-library-big",{"title":195,"path":196,"stem":197,"icon":24},"syscall","/stdlib/syscall","7.stdlib/syscall",{"id":199,"title":107,"body":200,"description":1265,"extension":1266,"links":1267,"meta":1268,"navigation":1269,"path":108,"seo":1270,"stem":109,"__hash__":1271},"docs/3.features/6.lambda.md",{"type":201,"value":202,"toc":1262},"minimark",[203,207,241,273,276,301,304,327,332,621,628,676,686,691,694,915,918,921,954,975,979,1163,1169,1176,1214,1220,1258],[204,205,206],"p",{},"A lambda expression is a convenient way to define an anonymous function object.\nwhich can either be used inline or passed as an argument.",[208,209,215],"pre",{"className":210,"code":211,"filename":212,"language":213,"meta":214,"style":214},"language-kh shiki shiki-themes material-theme-lighter one-light one-dark-pro","(parameters) => expression\n","syntax 1","kh","",[216,217,218],"code",{"__ignoreMap":214},[219,220,223,227,231,234,238],"span",{"class":221,"line":222},"line",1,[219,224,226],{"class":225},"sM89C","(",[219,228,230],{"class":229},"s8dPH","parameters",[219,232,233],{"class":225},") ",[219,235,237],{"class":236},"sB4Xn","=>",[219,239,240],{"class":229}," expression\n",[208,242,245],{"className":210,"code":243,"filename":244,"language":213,"meta":214,"style":214},"(parameters) => {\n\n}\n","syntax 2",[216,246,247,260,267],{"__ignoreMap":214},[219,248,249,251,253,255,257],{"class":221,"line":222},[219,250,226],{"class":225},[219,252,230],{"class":229},[219,254,233],{"class":225},[219,256,237],{"class":236},[219,258,259],{"class":225}," {\n",[219,261,263],{"class":221,"line":262},2,[219,264,266],{"emptyLinePlaceholder":265},true,"\n",[219,268,270],{"class":221,"line":269},3,[219,271,272],{"class":225},"}\n",[204,274,275],{},"Since lambdas are objects, they need a special data type to store them. Function pointers can be used for\nthis, however it might be a bit verbose. Therefore, a new syntax is introduced.",[208,277,280],{"className":210,"code":278,"filename":279,"language":213,"meta":214,"style":214},"return_type(parameter_types) identifier;\n","syntax",[216,281,282],{"__ignoreMap":214},[219,283,284,288,290,293,295,298],{"class":221,"line":222},[219,285,287],{"class":286},"spnjr","return_type",[219,289,226],{"class":225},[219,291,292],{"class":229},"parameter_types",[219,294,233],{"class":225},[219,296,297],{"class":229},"identifier",[219,299,300],{"class":225},";\n",[204,302,303],{},"For example:",[305,306,307,318],"ul",{},[308,309,310,313,314,317],"li",{},[216,311,312],{},"int()"," stores a lambda that returns value as an ",[216,315,316],{},"int"," and has no parameter.",[308,319,320,323,324,326],{},[216,321,322],{},"void(int)"," stores a lambda that return nothing and has one ",[216,325,316],{}," parameter.",[328,329,331],"h4",{"id":330},"lambda-example","Lambda Example",[208,333,335],{"className":210,"code":334,"language":213,"meta":214,"style":214},"int main(){\n\n  int(int, int) add = (int a, int b) => a + b;\n  int(int) square = (int n) => n * n;\n  void() hello = () => {\n    print(\"hello, pig\\n\");\n    print(\"hello, cow\\n\");\n    print(\"hello, chicken\\n\");\n  }\n\n  print(\"result: {}\\n\", add(2, 3));\n  print(\"result: {}\\n\", square(2));\n  hello();\n\n  return 0;\n}\n",[216,336,337,347,351,401,437,459,484,502,520,526,531,566,591,600,605,616],{"__ignoreMap":214},[219,338,339,341,344],{"class":221,"line":222},[219,340,316],{"class":229},[219,342,343],{"class":286}," main",[219,345,346],{"class":225},"(){\n",[219,348,349],{"class":221,"line":262},[219,350,266],{"emptyLinePlaceholder":265},[219,352,353,356,358,360,363,365,367,370,373,376,378,381,383,385,388,390,392,394,397,399],{"class":221,"line":269},[219,354,355],{"class":286},"  int",[219,357,226],{"class":225},[219,359,316],{"class":229},[219,361,362],{"class":225},", ",[219,364,316],{"class":229},[219,366,233],{"class":225},[219,368,369],{"class":229},"add",[219,371,372],{"class":236}," =",[219,374,375],{"class":225}," (",[219,377,316],{"class":229},[219,379,380],{"class":229}," a",[219,382,362],{"class":225},[219,384,316],{"class":229},[219,386,387],{"class":229}," b",[219,389,233],{"class":225},[219,391,237],{"class":236},[219,393,380],{"class":229},[219,395,396],{"class":236}," +",[219,398,387],{"class":229},[219,400,300],{"class":225},[219,402,404,406,408,410,412,415,417,419,421,424,426,428,430,433,435],{"class":221,"line":403},4,[219,405,355],{"class":286},[219,407,226],{"class":225},[219,409,316],{"class":229},[219,411,233],{"class":225},[219,413,414],{"class":229},"square",[219,416,372],{"class":236},[219,418,375],{"class":225},[219,420,316],{"class":229},[219,422,423],{"class":229}," n",[219,425,233],{"class":225},[219,427,237],{"class":236},[219,429,423],{"class":229},[219,431,432],{"class":236}," *",[219,434,423],{"class":229},[219,436,300],{"class":225},[219,438,440,444,447,450,452,455,457],{"class":221,"line":439},5,[219,441,443],{"class":442},"sQsOY","  void",[219,445,446],{"class":225},"() ",[219,448,449],{"class":229},"hello",[219,451,372],{"class":236},[219,453,454],{"class":225}," () ",[219,456,237],{"class":236},[219,458,259],{"class":225},[219,460,462,465,467,471,475,479,481],{"class":221,"line":461},6,[219,463,464],{"class":286},"    print",[219,466,226],{"class":225},[219,468,470],{"class":469},"sVH1b","\"",[219,472,474],{"class":473},"spZWa","hello, pig",[219,476,478],{"class":477},"scPpd","\\n",[219,480,470],{"class":469},[219,482,483],{"class":225},");\n",[219,485,487,489,491,493,496,498,500],{"class":221,"line":486},7,[219,488,464],{"class":286},[219,490,226],{"class":225},[219,492,470],{"class":469},[219,494,495],{"class":473},"hello, cow",[219,497,478],{"class":477},[219,499,470],{"class":469},[219,501,483],{"class":225},[219,503,505,507,509,511,514,516,518],{"class":221,"line":504},8,[219,506,464],{"class":286},[219,508,226],{"class":225},[219,510,470],{"class":469},[219,512,513],{"class":473},"hello, chicken",[219,515,478],{"class":477},[219,517,470],{"class":469},[219,519,483],{"class":225},[219,521,523],{"class":221,"line":522},9,[219,524,525],{"class":225},"  }\n",[219,527,529],{"class":221,"line":528},10,[219,530,266],{"emptyLinePlaceholder":265},[219,532,534,537,539,541,544,546,548,550,552,554,558,560,563],{"class":221,"line":533},11,[219,535,536],{"class":286},"  print",[219,538,226],{"class":225},[219,540,470],{"class":469},[219,542,543],{"class":473},"result: {}",[219,545,478],{"class":477},[219,547,470],{"class":469},[219,549,362],{"class":225},[219,551,369],{"class":286},[219,553,226],{"class":225},[219,555,557],{"class":556},"sriKn","2",[219,559,362],{"class":225},[219,561,562],{"class":556},"3",[219,564,565],{"class":225},"));\n",[219,567,569,571,573,575,577,579,581,583,585,587,589],{"class":221,"line":568},12,[219,570,536],{"class":286},[219,572,226],{"class":225},[219,574,470],{"class":469},[219,576,543],{"class":473},[219,578,478],{"class":477},[219,580,470],{"class":469},[219,582,362],{"class":225},[219,584,414],{"class":286},[219,586,226],{"class":225},[219,588,557],{"class":556},[219,590,565],{"class":225},[219,592,594,597],{"class":221,"line":593},13,[219,595,596],{"class":286},"  hello",[219,598,599],{"class":225},"();\n",[219,601,603],{"class":221,"line":602},14,[219,604,266],{"emptyLinePlaceholder":265},[219,606,608,611,614],{"class":221,"line":607},15,[219,609,610],{"class":442},"  return",[219,612,613],{"class":556}," 0",[219,615,300],{"class":225},[219,617,619],{"class":221,"line":618},16,[219,620,272],{"class":225},[204,622,623,627],{},[624,625,626],"strong",{},"Note",":",[208,629,631],{"className":210,"code":630,"language":213,"meta":214,"style":214},"void(int, int) add = (int a, int b) => a + b; \n",[216,632,633],{"__ignoreMap":214},[219,634,635,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674],{"class":221,"line":222},[219,636,637],{"class":442},"void",[219,639,226],{"class":225},[219,641,316],{"class":229},[219,643,362],{"class":225},[219,645,316],{"class":229},[219,647,233],{"class":225},[219,649,369],{"class":229},[219,651,372],{"class":236},[219,653,375],{"class":225},[219,655,316],{"class":229},[219,657,380],{"class":229},[219,659,362],{"class":225},[219,661,316],{"class":229},[219,663,387],{"class":229},[219,665,233],{"class":225},[219,667,237],{"class":236},[219,669,380],{"class":229},[219,671,396],{"class":236},[219,673,387],{"class":229},[219,675,300],{"class":225},[204,677,678,679,681,682,685],{},"This case will cause a compilation error because this ",[216,680,369],{}," suppposes to return nothing.\nTo solve the problem, ",[216,683,684],{},"=> {}"," code block should be use instead.\n(add function is a bad example anyway, but I think you get the point.)",[687,688,690],"h2",{"id":689},"closure","Closure",[204,692,693],{},"In Cambo, any variables used in the lambda are captured automatically. But lambdas do not capture all the\nvariables or objects in the scope, they only capture the ones that are used and also by value by default,\nmeaning modifying the captured will not affect the outer variables.",[208,695,697],{"className":210,"code":696,"language":213,"meta":214,"style":214},"int main(){\n\n  short x = 1000;\n  short y = 2000;\n  int count = 1;\n\n  // only `count` is captured by the lambda.\n  void() counter = () => {\n    count++;\n  }\n\n  print(\"old count: {}\\n\", count);  // output: 1\n  counter();\n  print(\"new count: {}\\n\", count);  // output: 1\n\n  return 0;\n}\n",[216,698,699,707,711,726,740,754,758,793,810,820,824,828,862,869,898,902,910],{"__ignoreMap":214},[219,700,701,703,705],{"class":221,"line":222},[219,702,316],{"class":229},[219,704,343],{"class":286},[219,706,346],{"class":225},[219,708,709],{"class":221,"line":262},[219,710,266],{"emptyLinePlaceholder":265},[219,712,713,716,719,721,724],{"class":221,"line":269},[219,714,715],{"class":442},"  short",[219,717,718],{"class":229}," x",[219,720,372],{"class":236},[219,722,723],{"class":556}," 1000",[219,725,300],{"class":225},[219,727,728,730,733,735,738],{"class":221,"line":403},[219,729,715],{"class":442},[219,731,732],{"class":229}," y",[219,734,372],{"class":236},[219,736,737],{"class":556}," 2000",[219,739,300],{"class":225},[219,741,742,744,747,749,752],{"class":221,"line":439},[219,743,355],{"class":229},[219,745,746],{"class":229}," count",[219,748,372],{"class":236},[219,750,751],{"class":556}," 1",[219,753,300],{"class":225},[219,755,756],{"class":221,"line":461},[219,757,266],{"emptyLinePlaceholder":265},[219,759,760,763,766,769,772,775,778,781,784,787,790],{"class":221,"line":486},[219,761,762],{"class":236},"  //",[219,764,765],{"class":229}," only",[219,767,768],{"class":225}," `",[219,770,771],{"class":229},"count",[219,773,774],{"class":225},"` ",[219,776,777],{"class":229},"is",[219,779,780],{"class":229}," captured",[219,782,783],{"class":229}," by",[219,785,786],{"class":229}," the",[219,788,789],{"class":229}," lambda",[219,791,792],{"class":225},".\n",[219,794,795,797,799,802,804,806,808],{"class":221,"line":504},[219,796,443],{"class":442},[219,798,446],{"class":225},[219,800,801],{"class":229},"counter",[219,803,372],{"class":236},[219,805,454],{"class":225},[219,807,237],{"class":236},[219,809,259],{"class":225},[219,811,812,815,818],{"class":221,"line":522},[219,813,814],{"class":229},"    count",[219,816,817],{"class":236},"++",[219,819,300],{"class":225},[219,821,822],{"class":221,"line":528},[219,823,525],{"class":225},[219,825,826],{"class":221,"line":533},[219,827,266],{"emptyLinePlaceholder":265},[219,829,830,832,834,836,839,841,843,845,847,850,853,856,859],{"class":221,"line":568},[219,831,536],{"class":286},[219,833,226],{"class":225},[219,835,470],{"class":469},[219,837,838],{"class":473},"old count: {}",[219,840,478],{"class":477},[219,842,470],{"class":469},[219,844,362],{"class":225},[219,846,771],{"class":229},[219,848,849],{"class":225},");  ",[219,851,852],{"class":236},"//",[219,854,855],{"class":229}," output",[219,857,858],{"class":225},": ",[219,860,861],{"class":556},"1\n",[219,863,864,867],{"class":221,"line":593},[219,865,866],{"class":286},"  counter",[219,868,599],{"class":225},[219,870,871,873,875,877,880,882,884,886,888,890,892,894,896],{"class":221,"line":602},[219,872,536],{"class":286},[219,874,226],{"class":225},[219,876,470],{"class":469},[219,878,879],{"class":473},"new count: {}",[219,881,478],{"class":477},[219,883,470],{"class":469},[219,885,362],{"class":225},[219,887,771],{"class":229},[219,889,849],{"class":225},[219,891,852],{"class":236},[219,893,855],{"class":229},[219,895,858],{"class":225},[219,897,861],{"class":556},[219,899,900],{"class":221,"line":607},[219,901,266],{"emptyLinePlaceholder":265},[219,903,904,906,908],{"class":221,"line":618},[219,905,610],{"class":442},[219,907,613],{"class":556},[219,909,300],{"class":225},[219,911,913],{"class":221,"line":912},17,[219,914,272],{"class":225},[204,916,917],{},"In the above example, count still stay the same as before.",[204,919,920],{},"In order to capture by reference, we have to write some a more verbose syntax but worth it.",[208,922,924],{"className":210,"code":923,"filename":279,"language":213,"meta":214,"style":214},"[]() => expression;\n[]() => {code block}\n",[216,925,926,938],{"__ignoreMap":214},[219,927,928,931,933,936],{"class":221,"line":222},[219,929,930],{"class":225},"[]() ",[219,932,237],{"class":236},[219,934,935],{"class":229}," expression",[219,937,300],{"class":225},[219,939,940,942,944,947,949,952],{"class":221,"line":262},[219,941,930],{"class":225},[219,943,237],{"class":236},[219,945,946],{"class":225}," {",[219,948,216],{"class":229},[219,950,951],{"class":229}," block",[219,953,272],{"class":225},[204,955,956,957,960,961,963,964,967,968,971,972,974],{},"You might be thinking this is even scarier than ",[216,958,959],{},"[](){}"," in C++ becuase of one additional ",[216,962,237],{},", just kidding.",[965,966],"br",{},"\nSimilar to lambda in C++, ",[216,969,970],{},"[]"," is used to capture outer variables. However, in Cambo, it's used to\ncapture by reference only (by value is done by default without using ",[216,973,970],{},").",[328,976,978],{"id":977},"example-capturing-by-reference","Example: Capturing By Reference",[208,980,982],{"className":210,"code":981,"language":213,"meta":214,"style":214},"int main(){\n\n  short x = 1000;\n  short y = 2000;\n  int count = 1;\n\n  \n  void() counter = [count]() => {\n    count++;\n  }\n\n  print(\"old count: {}\\n\", count);  // output: 1\n  counter();\n  print(\"new count: {}\\n\", count);  // output: 2\n\n\n  return 0;\n}\n",[216,983,984,992,996,1008,1020,1032,1036,1041,1063,1071,1075,1079,1107,1113,1142,1146,1150,1158],{"__ignoreMap":214},[219,985,986,988,990],{"class":221,"line":222},[219,987,316],{"class":229},[219,989,343],{"class":286},[219,991,346],{"class":225},[219,993,994],{"class":221,"line":262},[219,995,266],{"emptyLinePlaceholder":265},[219,997,998,1000,1002,1004,1006],{"class":221,"line":269},[219,999,715],{"class":442},[219,1001,718],{"class":229},[219,1003,372],{"class":236},[219,1005,723],{"class":556},[219,1007,300],{"class":225},[219,1009,1010,1012,1014,1016,1018],{"class":221,"line":403},[219,1011,715],{"class":442},[219,1013,732],{"class":229},[219,1015,372],{"class":236},[219,1017,737],{"class":556},[219,1019,300],{"class":225},[219,1021,1022,1024,1026,1028,1030],{"class":221,"line":439},[219,1023,355],{"class":229},[219,1025,746],{"class":229},[219,1027,372],{"class":236},[219,1029,751],{"class":556},[219,1031,300],{"class":225},[219,1033,1034],{"class":221,"line":461},[219,1035,266],{"emptyLinePlaceholder":265},[219,1037,1038],{"class":221,"line":486},[219,1039,1040],{"class":225},"  \n",[219,1042,1043,1045,1047,1049,1051,1054,1056,1059,1061],{"class":221,"line":504},[219,1044,443],{"class":442},[219,1046,446],{"class":225},[219,1048,801],{"class":229},[219,1050,372],{"class":236},[219,1052,1053],{"class":225}," [",[219,1055,771],{"class":229},[219,1057,1058],{"class":225},"]() ",[219,1060,237],{"class":236},[219,1062,259],{"class":225},[219,1064,1065,1067,1069],{"class":221,"line":522},[219,1066,814],{"class":229},[219,1068,817],{"class":236},[219,1070,300],{"class":225},[219,1072,1073],{"class":221,"line":528},[219,1074,525],{"class":225},[219,1076,1077],{"class":221,"line":533},[219,1078,266],{"emptyLinePlaceholder":265},[219,1080,1081,1083,1085,1087,1089,1091,1093,1095,1097,1099,1101,1103,1105],{"class":221,"line":568},[219,1082,536],{"class":286},[219,1084,226],{"class":225},[219,1086,470],{"class":469},[219,1088,838],{"class":473},[219,1090,478],{"class":477},[219,1092,470],{"class":469},[219,1094,362],{"class":225},[219,1096,771],{"class":229},[219,1098,849],{"class":225},[219,1100,852],{"class":236},[219,1102,855],{"class":229},[219,1104,858],{"class":225},[219,1106,861],{"class":556},[219,1108,1109,1111],{"class":221,"line":593},[219,1110,866],{"class":286},[219,1112,599],{"class":225},[219,1114,1115,1117,1119,1121,1123,1125,1127,1129,1131,1133,1135,1137,1139],{"class":221,"line":602},[219,1116,536],{"class":286},[219,1118,226],{"class":225},[219,1120,470],{"class":469},[219,1122,879],{"class":473},[219,1124,478],{"class":477},[219,1126,470],{"class":469},[219,1128,362],{"class":225},[219,1130,771],{"class":229},[219,1132,849],{"class":225},[219,1134,852],{"class":236},[219,1136,855],{"class":229},[219,1138,858],{"class":225},[219,1140,1141],{"class":556},"2\n",[219,1143,1144],{"class":221,"line":607},[219,1145,266],{"emptyLinePlaceholder":265},[219,1147,1148],{"class":221,"line":618},[219,1149,266],{"emptyLinePlaceholder":265},[219,1151,1152,1154,1156],{"class":221,"line":912},[219,1153,610],{"class":442},[219,1155,613],{"class":556},[219,1157,300],{"class":225},[219,1159,1161],{"class":221,"line":1160},18,[219,1162,272],{"class":225},[204,1164,1165,1166,1168],{},"Only ",[216,1167,771],{}," is captured by reference in the lambda. If x or y is used, they will be still captured by value.",[204,1170,1171,1172,1175],{},"But there's a way to caputured everything by reference. We can achieve this by using ",[216,1173,1174],{},"[*]",".",[208,1177,1179],{"className":210,"code":1178,"language":213,"meta":214,"style":214},"void() counter = [*]() => {\n    count++;\n}\n",[216,1180,1181,1202,1210],{"__ignoreMap":214},[219,1182,1183,1185,1187,1189,1191,1193,1196,1198,1200],{"class":221,"line":222},[219,1184,637],{"class":442},[219,1186,446],{"class":225},[219,1188,801],{"class":229},[219,1190,372],{"class":236},[219,1192,1053],{"class":225},[219,1194,1195],{"class":236},"*",[219,1197,1058],{"class":225},[219,1199,237],{"class":236},[219,1201,259],{"class":225},[219,1203,1204,1206,1208],{"class":221,"line":262},[219,1205,814],{"class":229},[219,1207,817],{"class":236},[219,1209,300],{"class":225},[219,1211,1212],{"class":221,"line":269},[219,1213,272],{"class":225},[204,1215,1216,1217,1219],{},"When ",[216,1218,1174],{}," is used instead, every outer variable used in the lambda will be all captured by reference\nand no by value will be possible.Lambda",[1221,1222,1223,1231],"note",{},[204,1224,1225,858,1228],{},[624,1226,1227],{},"keyword proposal",[216,1229,1230],{},"lambda",[305,1232,1233,1239,1249],{},[308,1234,1235,1236,1238],{},"We use ",[216,1237,1230],{}," keyword to tell the compiler to infer the type for us automatically.",[308,1240,1241,1242,362,1245,1248],{},"No need to write these things ",[216,1243,1244],{},"void(int, int)",[216,1246,1247],{},"int(float, string)",", etc.",[308,1250,1251,1252,1255,1256],{},"or maybe use ",[216,1253,1254],{},"auto"," instead of ",[216,1257,1230],{},[1259,1260,1261],"style",{},"html pre.shiki code .sM89C, html code.shiki .sM89C{--shiki-light:#90A4AE;--shiki-default:#383A42;--shiki-dark:#ABB2BF}html pre.shiki code .s8dPH, html code.shiki .s8dPH{--shiki-light:#90A4AE;--shiki-default:#E45649;--shiki-dark:#E06C75}html pre.shiki code .sB4Xn, html code.shiki .sB4Xn{--shiki-light:#39ADB5;--shiki-default:#383A42;--shiki-dark:#ABB2BF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spnjr, html code.shiki .spnjr{--shiki-light:#6182B8;--shiki-default:#4078F2;--shiki-dark:#61AFEF}html pre.shiki code .sQsOY, html code.shiki .sQsOY{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#A626A4;--shiki-default-font-style:inherit;--shiki-dark:#C678DD;--shiki-dark-font-style:inherit}html pre.shiki code .sVH1b, html code.shiki .sVH1b{--shiki-light:#39ADB5;--shiki-default:#50A14F;--shiki-dark:#98C379}html pre.shiki code .spZWa, html code.shiki .spZWa{--shiki-light:#91B859;--shiki-default:#50A14F;--shiki-dark:#98C379}html pre.shiki code .scPpd, html code.shiki .scPpd{--shiki-light:#90A4AE;--shiki-default:#0184BC;--shiki-dark:#56B6C2}html pre.shiki code .sriKn, html code.shiki .sriKn{--shiki-light:#F76D47;--shiki-default:#986801;--shiki-dark:#D19A66}",{"title":214,"searchDepth":262,"depth":262,"links":1263},[1264],{"id":689,"depth":262,"text":690},"Learn about lambda in Cambo","md",null,{},{"icon":24},{"title":107,"description":1265},"he0KmDaE43CPUpQgGHD7fN_cg5EoQ92ftIKIY2G5-zM",[1273,1275],{"title":103,"path":104,"stem":105,"description":1274,"icon":24,"children":-1},"Sharing is caring!",{"title":111,"path":112,"stem":113,"description":1276,"icon":24,"children":-1},"Call a function later on.",1774971229876]