{"id":1818,"date":"2023-09-22T09:05:24","date_gmt":"2023-09-22T00:05:24","guid":{"rendered":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/?p=1818"},"modified":"2023-09-22T10:44:03","modified_gmt":"2023-09-22T01:44:03","slug":"patters-dart3-0","status":"publish","type":"post","link":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/2023\/09\/22\/patters-dart3-0\/","title":{"rendered":"Patterns (@Dart3.0)"},"content":{"rendered":"\n<p>Patterns\uc5d0 \ub300\ud55c \ub2e4\uc74c \uc124\uba85\uc740<a href=\"https:\/\/dart.dev\/language\/records\" title=\"\">, <\/a><a href=\"https:\/\/dart.dev\/language\/patterns\" title=\"\">Dart \uacf5\uc2dd \uc0ac\uc774\ud2b8\uc758 \ub0b4\uc6a9(\uc544\ub798\uc758 \ucd9c\ucc98 \ucc38\uc870)<\/a>\uc744 \uae30\ubc18\uc73c\ub85c, \ub3c5\uc790\uc758 \uc774\ud574\ub97c \ub3d5\uae30 \uc704\ud55c \ucd94\uac00\uc801\uc778 \uae00\uc744 \ud3ec\ud568\ud558\uac70\ub098, \ucd9c\ucc98\uc758 \uae00\uc744 \uc218\uc815\ud558\ub294 \ubc29\uc2dd\uc73c\ub85c \uc791\uc131\ud558\uc600\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<p>Patterns\uc740 \uc2e4\uc81c\uc758 \uac12\uc5d0 \ub9e4\ud551\ub420 \uc218 \uc788\ub294 \uac12\ub4e4\uc758 &#8216;\ud615\ud0dc&#8217;\ub97c \uc758\ubbf8\ud569\ub2c8\ub2e4. \uccab\uc9f8\ub294 match\ub85c, \ubcc0\uc218\uac00 \uac12\uc744 \uac00\uc9c0\uace0 \uc788\uc744\ub54c, \uac12\uc5d0 \ub530\ub77c\uc11c \ub2e4\ub974\uac8c \ub3d9\uc791\ud558\uac8c \ud569\ub2c8\ub2e4. \ub458\uc9f8\ub294 destructure\ub85c, \ubcf5\ud569\uc801\uc778 \uac12\ub4e4\uc5d0\uc11c \uac1c\ubcc4\uc801\uc778 \uac12\ub4e4\uc744 \ucd94\ucd9c\ud560\uc218 \uc788\uc2b5\ub2c8\ub2e4. <\/p>\n\n\n\n<h4>Pattern Matching<\/h4>\n\n\n\n<p>\uac12\uc774 \uc8fc\uc5b4\uc9c4 \ud615\ud0dc(pattern, \uc774\ud6c4 \ud328\ud134)\uc5d0 \ubd80\ud569 \ud558\ub294\uc9c0 \ud655\uc778\ud558\ub294 \uae30\ub2a5\uc785\ub2c8\ub2e4. \ub300\ud45c\uc801\uc778 \uc608\uc81c\ub294 switch \uad6c\ubb38\uc785\ub2c8\ub2e4. \uc608\uc81c\ub294 1\uc774\ub77c\ub294 \uac12\uc774, number\uac00 \uac00\uc9c4 \uc0c1\uc218\uc758 pattern\uacfc \ub3d9\uc77c\ud55c \uac83\uc778\uc9c0 \uac80\uc0ac\ud558\ub294 \uc791\uc5c5\uc774\ub77c\uace0 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>switch (number) {\n  \/\/ Constant pattern matches if 1 == number.\n  case 1:\n    print('one');\n}<\/code><\/pre>\n\n\n\n<p>List\uc640 \uac19\uc740 collection type\uc744 \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0\ub294 List \ub77c\ub294 \uc0c1\uc704\uc758 \ud328\ud134\uacfc List\uc5d0 \uc18d\ud55c \ud56d\ubaa9\uc774\ub77c\ub294 \ud558\uc704\uc758 \ud328\ud134\uc73c\ub85c \uad6c\uc131\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774 \uacbd\uc6b0 \uc0c1\uc704 \ud328\ud134\uc744 outer \ud328\ud134, \ud558\uc704 \ud328\ud134\uc744 inner \ud328\ud134\uc774\ub77c\uace0 \ubd80\ub985\ub2c8\ub2e4. \uc544\ub798\uc758 \uc608\uc81c\ub294 outer \ud328\ud134\uc774 List\uc774\uba70, inner \ud328\ud134\uc774 \uc0c1\uc218 \ub450\uac1c\uc778 \uacbd\uc6b0\uc5d0 \ub300\ud55c pattern matching \uc608\uc2dc\ub97c \ubcf4\uc5ec\uc8fc\uace0 \uc788\uc2b5\ub2c8\ub2e4. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const a = 'a';\nconst b = 'b';\nList obj = &#91;a, b];\nswitch (obj) {\n  \/\/ List pattern &#91;a, b] matches obj first if obj is a list with two fields,\n  \/\/ then if its fields match the constant subpatterns 'a' and 'b'.\n  case &#91;a, b]:\n    print('$a, $b');\n}<\/code><\/pre>\n\n\n\n<h4>Pattern Destructuring<\/h4>\n\n\n\n<p>Pattern\uc740 \ubcf5\ud569\uc801\uc778 \uac12\uc744 \uad6c\uc131\ud558\ub294 \uac1c\ubcc4\uc801\uc778 \uac12\ub4e4\uc744 \ucd94\ucd9c\ud558\ub294 \uacbd\uc6b0\uc5d0\ub3c4 \ud65c\uc6a9\ud55c\ub2e4. \uc774\ub97c destructuring\uc774\ub77c\uace0 \ud55c\ub2e4. \uc608\ub97c \ub4e4\uc5b4 \ub2e4\uc74c\uc758 \uc608\uc2dc\uc5d0\uc11c\ub294 [1,2,3]\uc778 \ub9ac\uc2a4\ud2b8\uc5d0\uc11c \uac01\uac01\uc758 \uac12 1,2,3\uc744 \ucd94\ucd9c\ud558\uc5ec, \ub2e4\uc2dc \uac01\uac01 a,b,c\uc5d0 \ud560\ub2f9\ud558\ub294 \uac83\uc744 \ubcf4\uc5ec\uc900\ub2e4. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var numList = &#91;1, 2, 3];\n\/\/ List pattern &#91;a, b, c] destructures the three elements from numList...\nvar &#91;a, b, c] = numList;\n\/\/ ...and assigns them to new variables.\nprint(a + b + c);<\/code><\/pre>\n\n\n\n<p>Pattern destructuring\uc740 \ubcf4\ub2e4 \ubcf5\uc7a1\ud55c \ud615\ud0dc\ub85c\ub3c4 \uad6c\uc131\ud560 \uc218 \uc788\ub2e4. \uc544\ub798\uc758 \uc608\uc2dc\uc5d0\uc11c\ub294 \ub2e4\uc74c\uc758 \uc870\uac74\uc774 \ubaa8\ub450 \ub9de\uc744\ub54c c\ub97c \ucd9c\ub825\ud55c\ub2e4.<\/p>\n\n\n\n<p>\uccab\uc9f8\ub85c list\ub294 List \ud0c0\uc785 \uc774\uc5ec\uc57c \ud55c\ub2e4.<br>\ub458\uc9f8\ub85c list\uc758 \uccab\ubc88\uc9f8 \ud56d\ubaa9\uc774 \uac16\ub294 \uac12\uc740 \ubb38\uc790 &#8216;a&#8217; \ud639\uc740 &#8216;b&#8217; \uc774\uc5ec\uc57c \ud55c\ub2e4.<br>\uc138\uc9f8\ub85c list\ub294 \ub450\ubc88\uc9f8 \ud56d\ubaa9(c)\uc744 \uac16\uace0 \uc788\uc5b4\uc57c \ud55c\ub2e4.<\/p>\n\n\n\n<h4>Pattern Use Cases<\/h4>\n\n\n\n<p>Dart \uc5b8\uc5b4\uc5d0\uc11c\uc758 pattern \uc0ac\uc6a9 \ubc29\ubc95\uc740 \uc81c\ud55c\uc774 \uc5c6\uc73c\uba70, \ub2e4\uc74c\uc758 \ub300\ud45c\uc801\uc778 \uacbd\uc6b0\ub4e4\ub85c \uc124\uba85\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<ul><li>Local variable declarations and assignments<\/li><\/ul>\n\n\n\n<ul><li>for and for-in loops<\/li><\/ul>\n\n\n\n<ul><li>if-case and switch-case<\/li><\/ul>\n\n\n\n<ul><li>Control flow in collection literals<\/li><\/ul>\n\n\n\n<h4>Use Case: Variable Declaration<\/h4>\n\n\n\n<p>\ubcc0\uc218 \uc120\uc5b8\uc2dc \ud328\ud134\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc758 \uc608\uc81c\uc640 \uac19\uc740 \ubcf5\uc7a1\ud55c \ud615\ud0dc\uc758 \uac12\ub4e4\uc5d0\uc11c a,b,c\ub97c \ucd94\ucd9c\ud574 \ub0bc \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uba85\uc2ec\ud574\uc57c\ud560 \ubd80\ubd84\uc73c\ub85c, \ud328\ud134\uc744 \uc0ac\uc6a9\ud558\uc5ec \ubcc0\uc218\ub97c \uc120\uc5b8\ud558\ub294 \uacbd\uc6b0\uc5d0\ub294 \ubc18\ub4dc\uc2dc var \ud639\uc740 final\uc758 \ud615\ud0dc\ub85c \uc120\uc5b8\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Declares new variables a, b, and c.\nvar (a, &#91;b, c]) = ('str', &#91;1, 2]);<\/code><\/pre>\n\n\n\n<h4><meta charset=\"utf-8\">Use Case: Variable Assignment<\/h4>\n\n\n\n<p>\ubcc0\uc218 \uac12\uc744 \ud560\ub2f9\ud558\ub294 \uacbd\uc6b0\uc5d0 \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uac00\uc7a5 \uc720\uc6a9\ud55c \uc0ac\uc6a9\ubc95\uc740 \ubcf5\uc218\uc758 \uac12\uc744 \uc0c1\ud638 \uad50\ud658\ud558\ub294 swap\uc758 \uacbd\uc6b0\uc785\ub2c8\ub2e4. \ub2e4\uc74c\uc758 \uc608\uc81c\ub97c \ubcf4\uba74 (b, a) = (a, b)\uc640 \uac19\uc740 \ubc29\uc2dd\uc73c\ub85c \ub450 \ubcc0\uc218\uc758 \uac12\uc744 \ud55c \uc904\ub85c \ubcc0\uacbd\ud558\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var (a, b) = ('left', 'right');\n(b, a) = (a, b); \/\/ Swap.\nprint('$a $b'); \/\/ Prints \"right left\".<\/code><\/pre>\n\n\n\n<h4>Use Case: Conditional Statements (switch &amp; if)<\/h4>\n\n\n\n<p>\ud328\ud134\uc740 \uc870\uac74\ubb38\uc5d0\uc11c \ub2e4\uc591\ud55c \ud615\ud0dc\ub85c \ud65c\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uac00\uc7a5 \uae30\ubcf8\uc801\uc778 \uac83\uc740 switch \uad6c\ubb38\uc5d0\uc11c \uc870\uac74\uc5d0 \ubd80\ud569\ud558\ub294 \uacbd\uc6b0\uc5d0 \ud2b9\uc815 \uc791\uc5c5\uc744 \uc218\ud589\ud558\ub294 \uacbd\uc6b0\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>switch (obj) {\n  \/\/ Matches if 1 == obj.\n  case 1:\n    print('one');\n\n  \/\/ Matches if the value of obj is between the\n  \/\/ constant values of 'first' and 'last'.\n  case &gt;= first &amp;&amp; &lt;= last:\n    print('in range');\n\n  \/\/ Matches if obj is a record with two fields,\n  \/\/ then assigns the fields to 'a' and 'b'.\n  case (var a, var b):\n    print('a = $a, b = $b');\n\n  default:\n}<\/code><\/pre>\n\n\n\n<p>case 1:\uc740 obj\uac00 \uc815\uc218 1\uc758 \uac12\uc744 \uac00\uc9c4 \uacbd\uc6b0\uc5d0 \uc218\ud589\ud558\ub294 \ub3d9\uc791\uc744 \uc815\uc758\ud569\ub2c8\ub2e4. case &gt;= first &amp;&amp; &lt;= last:\ub294 obj\uac00 fisrt\uac00 \uac00\uc9c4 \uac12 \ubcf4\ub2e4 \ud06c\uac70\ub098 \uac19\uace0, last\uac00 \uac00\uc9c4 \uac12 \ubcf4\ub2e4 \uc791\uac70\ub098 \uac19\uc740 \uacbd\uc6b0\uc5d0 \uc218\ud589\ud558\ub294 \ub3d9\uc791\uc744 \uc815\uc758\ud569\ub2c8\ub2e4. case (var a, var b):\ub294 obj\uac00 \uc815\uc218 \ub450\uac1c\uc778 Record\uc778 \uacbd\uc6b0\uc5d0 \uc218\ud589\ud558\ub294 \ub3d9\uc791\uc744 \uc815\uc758\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\uc9c0\uae08\uae4c\uc9c0\uc640\ub294 \ub2e4\ub978 \ud615\ud0dc\uc758 switch \uad6c\ubb38\uc744 \ub2e4\uc74c\uc758 \uc608\uc81c\uc5d0\uc11c \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var isPrimary = switch (color) {\n  Color.red || Color.yellow || Color.blue =&gt; true,\n  _ =&gt; false\n};<\/code><\/pre>\n\n\n\n<p>\uc774 \ubb38\ubc95\uc740 color\uc758 \uac12\uc5d0 \ub530\ub77c\uc11c, true \ud639\uc740 false \uac12\uc744 isPrimary \ubcc0\uc218\uc5d0 \uc800\uc7a5\ud558\ub294 \uacbd\uc6b0\uc785\ub2c8\ub2e4. switch \uad6c\ubb38 \uc548\uc5d0 case \uad6c\ubb38\uc774 \uc5c6\uc2b5\ub2c8\ub2e4. \ub2e4\ub9cc \uc27c\ud45c(,)\ub85c \ubd84\ub9ac\ub41c \uad6c\ubb38\ub4e4\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub9ac\uace0 Dart\uc5d0\uc11c \uac04\ub2e8\ud55c \ud568\uc218\ub97c \ud55c\uc904\ub85c \ub9cc\ub4dc\ub294 \uacbd\uc6b0\uc5d0 \uc0ac\uc6a9\ud558\ub294 \ubb38\ubc95\uc778 =&gt;\uac00 \uc788\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub530\ub77c\uc11c switch \uad6c\ubb38 \uc548\uc758 \ub450 \uc904\uc740 \uac01\uac01 true \ud639\uc740 flase\ub97c \ub9ac\ud134\ud558\ub294 \uae30\ub2a5\uc744 \ud55c\ub2e4\uace0 \ubcf4\uba74 \ub429\ub2c8\ub2e4. \uadf8\ub807\ub2e4\uba74 =&gt; \uc55e\uc758 \ub0b4\uc6a9\uc774 \uad00\uac74\uc778\ub370, \ub17c\ub9ac \uc5f0\uc0b0\uc790 ||\ub294 OR\ub97c \uc758\ubbf8\ud55c\ub2e4\ub294 \ub0b4\uc6a9\uc744 \ud1a0\ub300\ub85c, \uccab\ubc88\uc9f8 \uc904\uc758 \uc758\ubbf8\ub294 color\uac00 \uac16\ub294 \uac12\uc774 Color.red \uc774\uac70\ub098 \ud639\uc740 Color.yellow \uc774\uac70\ub098 \ud639\uc740 Color.blue \uc778 \uacbd\uc6b0\uc5d0 true\ub97c isPrimary\uc5d0 \uc800\uc7a5\ud558\ub3c4\ub85d \ud55c\ub2e4\ub294 \uac83\uc744 \uc720\ucd94\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub9cc\uc57d \uc138\uac00\uc9c0 \uac12\uc5d0 color\uac00 \uac00\uc9c4 \uac12\uc774 \ubd80\ud569\ud558\uc9c0 \uc54a\uc73c\uba74 \ub450\ubc88\uc9f8 \uc904\uc774 \uc2e4\ud589\ub418\ub294\ub370, \uae30\ud638 &#8216;_&#8217;\ub294 \uc640\uc77c\ub4dc \uce74\ub4dc\ub77c\uace0 \ubd80\ub974\uba70, &#8216;\ubaa8\ub4e0 \uc870\uac74&#8217;\uc73c\ub85c \ud574\uc11d\ud569\ub2c8\ub2e4. \ub530\ub77c\uc11c, \uc138\uac00\uc9c0 \uc870\uac74\uc5d0 \ubd80\ud569\ud558\uc9c0 \uc54a\ub294 \ubaa8\ub4e0 \uacbd\uc6b0\uc5d0 \ub300\ud574\uc11c\ub294 false\ub97c isPrimary\uc5d0 \uc800\uc7a5\ud558\uac8c \ub429\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\uc774\ub807\uac8c \ud328\ud134\uc740 color\uc758 \uac12\uc774 \ub17c\ub9ac \uc5f0\uc0b0\uc790\uc758 \uc870\uac74 \ud639\uc740 \uc640\uc77c\ub4dc \uce74\ub4dc\uc5d0 \ubd80\ud569\ud558\ub294\uc9c0 \uc548\ud558\ub294\uc9c0\uc5d0 \ub530\ub978 \ucc28\ubcc4\uc801\uc778 \ub3d9\uc791 \uc815\uc758\uc5d0 \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ud574\ub2f9 \ub0b4\uc6a9\uc744 \uc77c\ubc18\uc801\uc778 switch \uad6c\ubb38\uc5d0 \uc0ac\uc6a9\ud55c \uc608\uc81c\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>switch (shape) {\n  case Square(size: var s) || Circle(size: var s) when s &gt; 0:\n    print('Non-empty symmetric shape');\n}<\/code><\/pre>\n\n\n\n<p>\uc608\uc81c\uc5d0\uc11c \ubcf4\ub4ef\uc774 switch \uad6c\ubb38\uc548\uc758 case\uc5d0 \ub17c\ub9ac \uc5f0\uc0b0\uc790\uc778 ||\ub97c \uc801\uc6a9\ud558\uc600\uc2b5\ub2c8\ub2e4. \ucd94\uac00\ub85c \ud55c\uac00\uc9c0 \ub354 \ud3ec\ud568\ud55c \uac83\uc740 case \uad6c\ubb38\uc758 \ub9c8\uc9c0\ub9c9\uc5d0 \uc788\ub294 when s > 0 \uc785\ub2c8\ub2e4. \uc774\ub294 || \ub17c\ub9ac \uc5f0\uc0b0\uc744 \uc218\ud589\ud558\uae30 \uc804\uc5d0 s \uac12\uc774 0\ubcf4\ub2e4 \ud070\uc9c0 \ud655\uc778\ud574\uc11c, 0\ubcf4\ub2e4 \ud070 \uacbd\uc6b0\uc5d0\ub9cc \ub17c\ub9ac \uc5f0\uc0b0 ||\ub97c \uc218\ud589\ud558\ub77c\ub294 \uc758\ubbf8\uc785\ub2c8\ub2e4. <\/p>\n\n\n\n<p>\ucd94\uac00\ub85c \uc54c\uc544\ubcfc if-case \uad6c\ubb38\uc740 \ud615\ud0dc\uac00 \ud2b9\uc774\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc758 \uacbd\uc6b0\ub97c \ubcf4\uba74, if \uc870\uac74\ubb38\uc5d0\uc11c json\uc758 \uac12\uc744 \ud655\uc778\ud558\ub294\ub370, <meta charset=\"utf-8\">case [&#8216;user&#8217;, var name]\uac00 json\uc5d0 \uc774\uc5b4\uc11c \ub098\ud0c0\ub09c \uac83\uc744 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub97c if-case \uad6c\ubb38\uc774\ub77c\uace0 \ud558\ub294\ub370, if-A-case-B\uc758 \ud615\ud0dc\ub85c \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \uc758\ubbf8\ub294 A\uac00 B\uc758 \ud328\ud134\uc774\ub77c\uba74 true, \uadf8\ub807\uc9c0 \uc54a\ub2e4\uba74 false\uc758 \uc758\ubbf8\ub85c \ub3d9\uc791\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (json case &#91;'user', var name]) {\n  print('Got user message for user $name.');\n}<\/code><\/pre>\n\n\n\n<h4>Use Case: Loop Statement (for, for-in)<\/h4>\n\n\n\n<p>\ud328\ud134\uc774\ub77c\uace0 \ubcf4\uae30 \uc5b4\ub824\uc6b8 \uc218 \uc788\uc9c0\ub9cc, \ubc18\ubcf5\ubb38\uc5d0 \ub300\ud574\uc11c\ub3c4 \ud328\ud134\uc758 \uac1c\ub150\uc744 \uc801\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc758 \uc608\uc81c\uc5d0\uc11c\ub294 for-in \ub8e8\ud504\uc5d0\uc11c \ud328\ud134\uc744 \uc0ac\uc6a9\ud558\uc5ec hist.entries\uac00 \ubc18\ud658\ud558\ub294 \ud56d\ubaa9\uc744 MapEntry \uac1d\uccb4 \ud615\ud0dc\ub85c destructureing \ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Map&lt;String, int&gt; hist = {\n  'a': 23,\n  'b': 100,\n};\n\nfor (var MapEntry(key: key, value: count) in hist.entries) {\n  print('$key occurred $count times');\n}<\/code><\/pre>\n\n\n\n<p>\ud328\ud134\uc740 hist.entries\uc5d0 \uba85\uba85\ub41c \uc720\ud615 MapEntry\uac00 \uc788\ub294\uc9c0 \ud655\uc778\ud55c \ub2e4\uc74c, \uba85\uba85\ub41c \ud544\ub4dc \ud558\uc704 \ud328\ud134\uc758 \ud0a4\uc640 \uac12\uc73c\ub85c \ubc18\ubcf5\ub429\ub2c8\ub2e4. \uac01 \ubc18\ubcf5\uc5d0\uc11c MapEntry\uc758 key getter \ubc0f value getter\ub97c \ud638\ucd9c\ud558\uace0 \uacb0\uacfc\ub97c \uac01\uac01 \ub85c\uceec \ubcc0\uc218 key \ubc0f count\uc5d0 \ubc14\uc778\ub529\ud569\ub2c8\ub2e4. <\/p>\n\n\n\n<p>getter \ud638\ucd9c \uacb0\uacfc\ub97c \ub3d9\uc77c\ud55c \uc774\ub984\uc758 \ubcc0\uc218\uc5d0 \ubc14\uc778\ub529\ud558\ub294 \uac83\uc774 \uc77c\ubc18\uc801\uc778 \uc0ac\uc6a9 \uc0ac\ub840\uc774\ubbc0\ub85c, \uc774 \uacbd\uc6b0\uc758 \ud328\ud134\uc740 \ubcc0\uc218 \ud558\uc704 \ud328\ud134\uc5d0\uc11c getter \uc774\ub984\uc744 \ucd94\ub860\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub97c \ud1b5\ud574 key: key\uc640 \uac19\uc740 \uc911\ubcf5\ub41c \uac83\uc5d0\uc11c :key:\ub85c \ubcc0\uc218 \ud328\ud134\uc744 \ub2e4\uc74c\uc758 \uc608\uc81c\uc640 \uac19\uc774 \ub2e8\uc21c\ud654\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub9cc\uc57d \ub450\ubc88\uc9f8 \ud56d\ubaa9\uc744 (\uc704\uc758 \ucf54\ub4dc\uc5d0\uc11c) value:value\ub85c \uba85\uba85\ud588\ub2e4\uba74, \ub2e4\uc74c\uc758 \ucf54\ub4dc\uc5d0\uc11c :value\ub85c \ub2e8\uc21c\ud654 \ud558\ub294 \uac83\ub3c4 \uac19\uc740 \ub9e5\ub77d\uc5d0\uc11c \uac00\ub2a5\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (var MapEntry(:key, value: count) in hist.entries) {\n  print('$key occurred $count times');\n}<\/code><\/pre>\n\n\n\n<h4>Pattern Types (MORE TO READ)<\/h4>\n\n\n\n<p><a href=\"https:\/\/dart.dev\/language\/pattern-types\" title=\"\">Dart \uc5b8\uc5b4 \uacf5\uc2dd \ud648\ud398\uc774\uc9c0<\/a>\uc5d0\uc11c\ub294 \ub2e4\uc591\ud55c \uc885\ub958\uc758 \ud328\ud134\uc5d0 \ub300\ud55c \uc124\uba85\uc744 \uc0c1\uc138\ud558\uac8c \uc81c\uacf5\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. <\/p>\n\n\n\n<ul id=\"toc\"><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#logical-or\">Logical-or<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#logical-and\">Logical-and<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#relational\">Relational<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#cast\">Cast<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#null-check\">Null-check<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#null-assert\">Null-assert<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#constant\">Constant<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#variable\">Variable<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#identifier\">Identifier<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#parenthesized\">Parenthesized<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#list\">List<\/a><ul><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#rest-element\">Rest element<\/a><\/li><\/ul><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#map\">Map<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#record\">Record<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#object\">Object<\/a><\/li><li><a href=\"https:\/\/dart.dev\/language\/pattern-types#wildcard\">Wildcard<\/a><\/li><\/ul>\n\n\n\n<p>\uc774\ubc88 \uae00\uc5d0\uc11c \ud328\ud134\uc5d0 \ub300\ud55c \uac1c\uad04\uc801\uc778 \ub0b4\uc6a9\uc744 \ub2e4\ub918\ub2e4\uba74, \uc774\ub97c \ud65c\uc6a9\ud558\ub294 \uacbd\uc6b0\uc5d0\ub294 case-by-case\ub85c \uc0b4\ud3b4\ubd10\uc57c\ud560 \uc0ac\ud56d\ub4e4\uc774 \ubc1c\uc0dd\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774 \uacbd\uc6b0, \uacf5\uc2dd \uc0ac\uc774\ud2b8\uc5d0\uc11c \uc0ac\ub840\ubcc4 \ud65c\uc6a9 \ubc29\ubc95\uc744 \uc0b4\ud3b4\ubcf4\uba74 \uc2dc\ud589\ucc29\uc624\uc5d0 \ub530\ub978 \uc2dc\uac04\uc744 \uc904 \uc77c\uc218 \uc788\uc744 \uac81\ub2c8\ub2e4.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>[\ucd9c\ucc98] <a href=\"https:\/\/dart.dev\/language\/patterns\">https:\/\/dart.dev\/language\/patterns<\/a><\/p>\n\n\n\n<p>[\ucd9c\ucc98] <a href=\"https:\/\/dart.dev\/language\/pattern-types\">https:\/\/dart.dev\/language\/pattern-types<\/a><\/p>\n\n\n\n<p>[\ucd9c\ucc98] <a href=\"https:\/\/github.com\/dart-lang\/sdk\/blob\/master\/CHANGELOG.md#300---2023-05-10\">https:\/\/github.com\/dart-lang\/sdk\/blob\/master\/CHANGELOG.md#300&#8212;2023-05-10<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Patterns\uc5d0 \ub300\ud55c \ub2e4\uc74c \uc124\uba85\uc740, Dart \uacf5\uc2dd \uc0ac\uc774\ud2b8\uc758 \ub0b4\uc6a9(\uc544\ub798\uc758 \ucd9c\ucc98 \ucc38\uc870)\uc744 \uae30\ubc18\uc73c\ub85c, \ub3c5\uc790\uc758 \uc774\ud574\ub97c \ub3d5\uae30 \uc704\ud55c \ucd94\uac00\uc801\uc778 \uae00\uc744 \ud3ec\ud568\ud558\uac70\ub098, \ucd9c\ucc98\uc758 \uae00\uc744 \uc218\uc815\ud558\ub294 \ubc29\uc2dd\uc73c\ub85c \uc791\uc131\ud558\uc600\uc2b5\ub2c8\ub2e4. Patterns\uc740 \uc2e4\uc81c\uc758 \uac12\uc5d0 \ub9e4\ud551\ub420 \uc218 \uc788\ub294 \uac12\ub4e4\uc758 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":1748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[3],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/posts\/1818"}],"collection":[{"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=1818"}],"version-history":[{"count":7,"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/posts\/1818\/revisions"}],"predecessor-version":[{"id":1833,"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/posts\/1818\/revisions\/1833"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/media\/1748"}],"wp:attachment":[{"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=1818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=1818"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mobilelab.khu.ac.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=1818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}