{"id":127921,"date":"2020-06-06T21:50:19","date_gmt":"2020-06-06T13:50:19","guid":{"rendered":"http:\/\/4563.org\/?p=127921"},"modified":"2020-06-06T21:50:19","modified_gmt":"2020-06-06T13:50:19","slug":"%e5%88%9d%e5%85%a5-kotlin%ef%bc%8c%e6%ba%90%e7%a0%81%e6%89%be%e4%b8%8d%e8%a7%81%e6%b1%82%e6%95%99","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=127921","title":{"rendered":"\u521d\u5165 kotlin\uff0c\u6e90\u7801\u627e\u4e0d\u89c1\u6c42\u6559"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u521d\u5165 kotlin\uff0c\u6e90\u7801\u627e\u4e0d\u89c1\u6c42\u6559               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : q13859601 <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>fun main() {     val numbersMap = mutableMapOf(\"one\" to 1, \"two\" to 2, \"three\" to 3, \"threeAgain\" to 3)     numbersMap.keys.remove(\"one\")     println(numbersMap)     numbersMap.values -= 3     println(numbersMap)     numbersMap.values.remove(3)     println(numbersMap) } <\/code><\/pre>\n<p>\u5bf9\u4e8e<code>numbersMap.values -= 3<\/code> \u8fd9\u4e2a<code>-=<\/code>\u7684\u8fd0\u7b97\u7b26\u91cd\u8f7d\u7684\u6e90\u7801\u5728\u54ea\u91cc\u5462\uff0c\u96be\u9053\u662f native \u4e48 ide \u91cc\u9762\u70b9\u4e86\u534a\u5929\u90fd\u662f MutableCollection \u7684 minusAssign \u65b9\u6cd5\uff0c\u4f46\u662f\u5e76\u4e0d\u6e05\u695a\u8fd9\u4e2a\u5185\u90e8\u7684 values:MutableCollection \u7684-=\u7684\u91cd\u5199\u5982\u4f55\u5173\u8054\u5230 map \u7684 entry \u7684\u5220\u9664\u7684<\/p>\n<p>\u6c42\u5927\u795e\u6307\u5bfc:D<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>7<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2164141\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuankui <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u662f mac\uff0c\u53ef\u4ee5\u6309\u4f4f cmd+\u9f20\u6807\u5de6\u952e\u5355\u51fb&#8221;-=&#8221;\uff0c\u53ef\u4ee5\u5230\u8fbe\u65b9\u6cd5\u7684\u5b9a\u4e49\u3002<br \/>\u5177\u4f53\u5b9e\u73b0\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff0cextension method                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2164142\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuankui <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/kotlinlang.org\/docs\/reference\/operator-overloading.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2164143\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : q13859601 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @yuankui \u611f\u8c22\u5e2e\u52a9~<br \/>\u70b9\u8fdb\u53bb\u770b\u4e86\u4e5f\u53ea\u662f\u4e2a\u63a5\u53e3\u5b9a\u4e49\uff0c\u6ca1\u6709\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\uff1b<br \/>\u6269\u5c55\u65b9\u6cd5\u548c\u8fd0\u7b97\u7b26\u91cd\u8f7d\u4e5f\u80fd\u7406\u89e3\uff0c\u5173\u952e\u95ee\u9898\u662f\uff0c\u8fd9\u4e2a\u6e90\u7801\u5230\u5e95\u5728\u54ea\u91cc\uff0c\u901a\u8fc7 IDE \u5982\u4f55\u627e\u5230\u8fd9\u4e2a\u6e90\u7801\u6216\u8005\u662f\u6587\u6863\u600e\u4e48\u7ffb\u8fd9\u4e2a\u7d22\u5f15\u624d\u80fd\u627e\u5230- -\uff0c\u6211\u53ef\u80fd\u662f\u61d2\u5427\uff0c\u4f46\u662f\u771f\u7684\u6ca1\u529e\u6cd5\u50cf java \u4e00\u6837 IDEA \u91cc\u76f4\u63a5\u64b8\u5c31\u80fd\u7ffb\u5230\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2164144\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ChenFanlin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u8fd9\u8fb9\u76f4\u63a5\u70b9\u8fdb\u53bb\u662f\u6709\u7684 <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/06\/20200629_5ef993700cc53.png\" rel=\"noreferrer\" alt=\"\u521d\u5165 kotlin\uff0c\u6e90\u7801\u627e\u4e0d\u89c1\u6c42\u6559\"> <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2164145\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : q13859601 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ChenFanlin <br \/>\u55ef\u55ef \u8fd9\u4e2a\u6211\u4e5f\u662f\u53ef\u4ee5\u770b\u5230\u7684\uff0c\u4f46\u662f\u8fd9\u4e2a\u662f MutableCollection.minusAssign\uff0c\u4e5f\u5c31\u662f\u8bf4\u4ed6\u662f values \u7684 minusAssign\uff0c\u8c03\u7528\u7684\u662f<br \/>MutableCollection \u63a5\u53e3\u7684 remove \u65b9\u6cd5\uff0c\u6211\u662f\u60f3\u627e\u5230 LinkedHashMap \u7684 values \u5b9e\u73b0\u7c7b\u7684 remove \u65b9\u6cd5\u7684\u5b9e\u73b0\uff0c\u8fd9\u91cc\u9762\u5e94\u8be5\u6709\u5173\u8054\u5220\u9664 map entry \u7684\u903b\u8f91                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2164146\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ChenFanlin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @q13859601 #5 <br \/>&#8211; \u5c31\u662f\u8c03\u7528\u4e86 remove \u65b9\u6cd5, \u90a3\u5c31\u662f\u76f8\u5f53\u4e8e map.values().remove(), \u76f4\u63a5\u53bb LinkedHashMap \u6e90\u7801\u770b\u597d\u4e86. values() <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/06\/20200629_5ef9937342aa5.png\" rel=\"noreferrer\" alt=\"\u521d\u5165 kotlin\uff0c\u6e90\u7801\u627e\u4e0d\u89c1\u6c42\u6559\">, AbstractCollection.remove() <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/06\/20200629_5ef99377af64f.png\" rel=\"noreferrer\" alt=\"\u521d\u5165 kotlin\uff0c\u6e90\u7801\u627e\u4e0d\u89c1\u6c42\u6559\">,LinkedHashIterator.remove() <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/06\/20200629_5ef9937ade919.png\" rel=\"noreferrer\" alt=\"\u521d\u5165 kotlin\uff0c\u6e90\u7801\u627e\u4e0d\u89c1\u6c42\u6559\"> <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2164147\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : q13859601 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ChenFanlin <br \/>\u660e\u767d\u4e86 \u611f\u8c22\uff0c\u5b9e\u73b0\u5b9e\u9645\u662f jdk \u7684\uff0c\u800c\u8fd9\u4e2a values \u91cc\u9762\u5b58\u7684\u662f node\uff0c\u611f\u8c22\u6700\u7ec8\u59d4\u6258\u7ed9\u4e86 HashMap \u7684 removeNode                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u521d\u5165 kotlin\uff0c\u6e90\u7801\u627e\u4e0d\u89c1\u6c42\u6559&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/127921"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127921"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/127921\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127921"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}