很多开发人员都存在这种误解,认为使用lambda表达式会导致代码冗余,降低代码质量。恰恰相反,就算代码变得再复杂,我们也不会为了代码的简洁性而在代码质量上做任何妥协,下面我们就会看到。
在前面一个例子中我们已经可以重用lambda表达式了;然而,如果再匹配另外一个字母,代码冗余的问题很快又卷土重来了。我们先来进一步分析下这个问题,然后再用词法作用域和闭包来把它解决掉。
网址
http://club.news.sohu.com/help/thread/2793yf6o3l4
http://club.health.sohu.com/zz0094/thread/2794714m1yf
http://club.health.sohu.com/zz0094/thread/27948oqftjs
http://club.health.sohu.com/zz0094/thread/2794apxv16v
http://club.health.sohu.com/zz0094/thread/2794cx7cfro
http://club.health.sohu.com/zz0094/thread/2794i3zebri
http://club.health.sohu.com/zz0094/thread/2794s5azgv8
http://club.health.sohu.com/zz0094/thread/2794vkrjz4w
http://club.health.sohu.com/zz0094/thread/2794xbpyf2s
http://club.health.sohu.com/zz0094/thread/2794zjddgzc
http://club.health.sohu.com/zz0094/thread/27951um30mz
http://club.health.sohu.com/zz0094/thread/27953n1n8kb
http://club.health.sohu.com/zz0094/thread/279590znyy6
http://club.health.sohu.com/zz0094/thread/27961y5k7o7
http://club.health.sohu.com/zz0094/thread/27964odoibo
http://club.health.sohu.com/zz0094/thread/27966pes62g
http://club.health.sohu.com/zz0094/thread/27968rvez2b
http://club.health.sohu.com/zz0094/thread/2796awukaxt
http://club.health.sohu.com/zz0094/thread/2796fntb3mn
http://club.health.sohu.com/zz0094/thread/2796hm6c137
http://club.health.sohu.com/zz0094/thread/2796joyyeo8
http://club.health.sohu.com/zz0094/thread/2796m0prj15
http://www.4shared.com/mp3/7yGEY6DNce/2014-03-20JD.html
http://www.4shared.com/photo/kHrkx_OWba/2014-03-20JD.html
http://www.4shared.com/mp3/gOOjiR4Sba/2014-03-20JD.html
http://www.4shared.com/photo/egk6O80ece/2014-03-20JD.html
http://www.4shared.com/photo/JQTQGfXsce/2014-03-20JD.html
http://www.4shared.com/photo/4vb1CUZHce/2014-03-20JD.html
http://www.4shared.com/photo/xK4_ryg_ce/2014-03-20JD.html
http://www.4shared.com/photo/raKWiNYSba/2014-03-20JD.html
http://www.4shared.com/photo/IJ1MFlGYba/2014-03-20JD.html
http://www.4shared.com/photo/IgkmNCPece/2014-03-20JD.html
http://www.4shared.com/photo/FdAsMaBeba/2014-03-20JD.html
http://www.4shared.com/photo/pCqonckEce/2014-03-20JD.html
http://www.4shared.com/photo/ZPpW_DIAce/2014-03-20JD.html
http://www.4shared.com/photo/IsctQoBLce/2014-03-20JD.html
http://www.4shared.com/photo/hNBu7GRjce/2014-03-20JD.html
http://www.4shared.com/photo/J6QHX0ohba/2014-03-20JD.html
http://www.4shared.com/photo/R-ywsaC_ba/2014-03-20JD.html
http://www.4shared.com/photo/l-1pGB6Yce/2014-03-20JD.html
http://www.4shared.com/photo/dwGsggBCba/2014-03-20JD.html
http://www.4shared.com/photo/JQ9Vzzcrba/2014-03-20JD.html
http://www.4shared.com/photo/oytC0I9Nba/2014-03-20JD.html
http://www.4shared.com/photo/Nz6EKi-dce/2014-03-20JD.html
http://www.4shared.com/photo/JcXjn6iEce/2014-03-20JD.html
http://www.4shared.com/photo/sLNK1Np4ba/2014-03-20JD.html
http://www.4shared.com/photo/h2FC6HDzce/2014-03-20JD.html
http://www.4shared.com/photo/YImLeT_lce/2014-03-20JD.html
http://www.4shared.com/photo/xSc6N-KKce/2014-03-20JD.html
http://www.4shared.com/photo/rRnhun4pba/2014-03-20JD.html
http://www.4shared.com/photo/XsJkUgzMba/2014-03-20JD.html
http://www.4shared.com/photo/SEZrV6QMce/2014-03-20JD.html
http://www.4shared.com/photo/e-dV2osOba/2014-03-20JD.html
http://www.4shared.com/photo/cEf6p_KUce/2014-03-20JD.html
http://www.4shared.com/photo/VE-krjjpce/2014-03-20JD.html
http://www.4shared.com/photo/RhEllrPnba/2014-03-20JD.html
http://www.4shared.com/photo/vSZGKQ-Jba/2014-03-20JD.html
http://www.4shared.com/photo/bz_HF5Usba/2014-03-20JD.html
http://www.4shared.com/photo/KiMxfxmSba/2014-03-20JD.html
http://www.4shared.com/photo/KYBWJGIdba/2014-03-20JD.html
http://www.4shared.com/photo/IzFYqbZoba/2014-03-20JD.html
http://www.4shared.com/photo/B_p5xTKqce/2014-03-20JD.html
http://www.4shared.com/photo/LRD80G1hba/2014-03-20JD.html
http://www.4shared.com/photo/4y1uUQBMce/2014-03-20JD.html
http://www.4shared.com/photo/dU_JtzVpba/2014-03-20JD.html
http://www.4shared.com/photo/ONzLXZp3ce/2014-03-20JD.html
http://www.4shared.com/photo/rQcaHEgJba/2014-03-20JD.html
http://www.4shared.com/photo/z6tGXIoNce/2014-03-20JD.html
http://www.4shared.com/photo/5xRAleT9ce/2014-03-20JD.html
http://www.4shared.com/photo/lXTrHYkJce/2014-03-20JD.html
http://www.4shared.com/photo/ZxkNIjqtce/2014-03-20JD.html
http://www.4shared.com/photo/TwEYt-IFba/2014-03-20JD.html
http://www.4shared.com/photo/K7WqWM6Mce/2014-03-20JD.html
http://www.4shared.com/photo/nrECSE9Lba/2014-03-20JD.html
http://www.4shared.com/photo/1mGBjtnTba/2014-03-20JD.html
http://www.4shared.com/photo/f7X-IhwZce/2014-03-20JD.html
http://www.4shared.com/photo/FjJqzMkHba/2014-03-20JD.html
http://www.4shared.com/photo/FTTDFWTcce/2014-03-20JD.html
http://www.4shared.com/photo/VpAEu99pce/2014-03-20JD.html
http://www.4shared.com/photo/d9mUX5bxba/2014-03-20JD.html
http://www.4shared.com/photo/dg89x4Lace/2014-03-20JD.html
http://www.4shared.com/photo/jTgUV-HMba/2014-03-20JD.html
http://www.4shared.com/photo/YmXZbxdRce/2014-03-20JD.html
http://www.4shared.com/photo/x-Ssec7Bba/2014-03-20JD.html
http://www.4shared.com/photo/7TlBXpn3ba/2014-03-20JD.html
http://www.4shared.com/photo/xU8Fay-6ba/2014-03-20JD.html
http://www.4shared.com/photo/ssnAg6CCce/2014-03-20JD.html
http://www.4shared.com/photo/XMyYVcJMce/2014-03-20JD.html
http://www.4shared.com/photo/YR1VaAYAba/2014-03-20JD.html
http://www.4shared.com/photo/YPTuEGBcba/2014-03-20JD.html
http://www.4shared.com/photo/Tv8wlhSTba/2014-03-20JD.html
http://www.4shared.com/photo/V-v_HogJce/2014-03-20JD.html
http://www.4shared.com/photo/T2oRqkXEce/2014-03-20JD.html
http://www.4shared.com/photo/wqmGAFEXba/2014-03-20JD.html
http://www.4shared.com/photo/ylDR4tX4ce/2014-03-20JD.html
http://www.4shared.com/photo/LJBnMTzuce/2014-03-20JD.html
http://www.4shared.com/photo/M0mr6PAzba/2014-03-20JD.html
http://www.4shared.com/photo/PgOvwYBGce/2014-03-20JD.html
http://www.4shared.com/photo/jZwHDYoIce/2014-03-20JD.html
http://www.4shared.com/photo/maUnFZPYce/2014-03-20JD.html
http://www.4shared.com/photo/MuTIZhV3ba/2014-03-20JD.html
http://www.4shared.com/photo/2w59T6fMba/2014-03-20JD.html
http://www.4shared.com/photo/O8WJDupcba/2014-03-20JD.html
http://www.4shared.com/photo/xeOuEMBIce/2014-03-20JD.html
http://www.4shared.com/photo/2LqyKG8dba/2014-03-20JD.html
http://www.4shared.com/photo/IZEn_VP6ba/2014-03-20JD.html
http://www.4shared.com/photo/7UKZostEce/2014-03-20JD.html
http://www.4shared.com/photo/rNm3jie9ba/2014-03-20JD.html
http://www.4shared.com/photo/6KfzlPSnba/2014-03-20JD.html
http://www.4shared.com/photo/G7hzVPSwce/2014-03-20JD.html
http://www.4shared.com/photo/80SkjdjTce/2014-03-20JD.html
http://www.4shared.com/photo/UcGz6ZC5ce/2014-03-20JD.html
http://www.4shared.com/photo/kEZbs0w_ce/2014-03-20JD.html
http://www.4shared.com/photo/UxENOmWece/2014-03-20JD.html
http://www.4shared.com/photo/Yb6Xi2YCba/2014-03-20JD.html
http://www.4shared.com/photo/X5AXyUYGba/2014-03-20JD.html
http://www.4shared.com/photo/rmulfojCba/2014-03-20JD.html
http://www.4shared.com/photo/M45mGN5Yba/2014-03-20JD.html
http://www.4shared.com/photo/HESFRsULba/2014-03-20JD.html
http://www.4shared.com/photo/OPE-R8Lfce/2014-03-20JD.html
http://www.4shared.com/mp3/Xt8KxIVGba/2014-03-20JD.html
http://www.4shared.com/mp3/ymVSfFbSce/2014-03-20JD.html
http://www.4shared.com/mp3/Py9ulIRDce/2014-03-20JD.html
http://www.4shared.com/mp3/qWWdCt3Xce/2014-03-20JD.html
http://www.4shared.com/mp3/Up8pssAFce/2014-03-20JD.html
http://www.4shared.com/mp3/yAfyLumeba/2014-03-20JD.html
http://www.4shared.com/mp3/i-5oTbkwce/2014-03-20JD.html
http://www.4shared.com/mp3/nxlwb2lBba/2014-03-20JD.html
http://www.4shared.com/mp3/ohC6n6eEce/2014-03-20JD.html
http://www.4shared.com/mp3/rB1dGq3cba/2014-03-20JD.html
http://www.4shared.com/mp3/X1g230Jice/2014-03-20JD.html
http://www.4shared.com/mp3/WUk4ZvKxce/2014-03-20JD.html
http://www.4shared.com/mp3/2uVm8E5Pce/2014-03-20JD.html
http://www.4shared.com/mp3/vMnA2WCiba/2014-03-20JD.html
http://www.4shared.com/mp3/GE6JMrFuce/2014-03-20JD.html
http://www.4shared.com/mp3/NfZAhdTSce/2014-03-20JD.html
http://www.4shared.com/mp3/mf0OAJqXce/2014-03-20JD.html
http://www.4shared.com/mp3/OFnnhLPmce/2014-03-20JD.html
http://www.4shared.com/mp3/yX9UubYpba/2014-03-20JD.html
http://www.4shared.com/mp3/_p9bRSMfce/2014-03-20JD.html
http://www.4shared.com/mp3/A4juyu7aba/2014-03-20JD.html
http://www.4shared.com/mp3/65GzeU8Bba/2014-03-20JD.html
http://www.4shared.com/mp3/PTI3FoKIba/2014-03-20JD.html
http://www.4shared.com/mp3/e4qQA6qHce/2014-03-20JD.html
http://www.4shared.com/mp3/yU2VGtYYce/2014-03-20JD.html
http://www.4shared.com/mp3/kQ-lfrjmba/2014-03-20JD.html
http://www.4shared.com/mp3/c7k2m0Z9ba/2014-03-20JD.html
http://www.4shared.com/mp3/W4_UBbIrba/2014-03-20JD.html
http://www.4shared.com/mp3/CHDoY4zhba/2014-03-20JD.html
http://www.4shared.com/mp3/LcxFLlo0ce/2014-03-20JD.html
http://www.4shared.com/mp3/DUFGnvooba/2014-03-20JD.html
http://www.4shared.com/mp3/XAHOTzawba/2014-03-20JD.html
http://www.4shared.com/mp3/fOraJqMdba/2014-03-20JD.html
http://www.4shared.com/mp3/IFa3Pfevce/2014-03-20JD.html
http://www.4shared.com/mp3/3rGvLNl0ba/2014-03-20JD.html
http://www.4shared.com/mp3/M38CbHnlce/2014-03-20JD.html
http://www.4shared.com/mp3/Nw3lNtP0ce/2014-03-20JD.html
http://www.4shared.com/mp3/jFU3an0kce/2014-03-20JD.html
http://www.4shared.com/mp3/RwEhtaO_ce/2014-03-20JD.html
http://www.4shared.com/mp3/rfoX7EIPce/2014-03-20JD.html
http://www.4shared.com/mp3/lHphZ_N3ce/2014-03-20JD.html
http://www.4shared.com/mp3/fSx3kbunce/2014-03-20JD.html
http://www.4shared.com/mp3/J1zyUsCMce/2014-03-20JD.html
http://www.4shared.com/mp3/mghxd8R7ba/2014-03-20JD.html
http://www.4shared.com/mp3/j3iuMpB0ba/2014-03-20JD.html
http://www.4shared.com/mp3/OkF_Sk2Lce/2014-03-20JD.html
http://www.4shared.com/mp3/psWTuXXpba/2014-03-20JD.html
http://www.4shared.com/mp3/gK8CfDnmce/2014-03-20JD.html
http://www.4shared.com/mp3/aDuLGM_Iba/2014-03-20JD.html
http://www.4shared.com/mp3/PVES8rXzce/2014-03-20JD.html
http://www.4shared.com/mp3/HsBqQBA1ce/2014-03-20JD.html
http://www.4shared.com/mp3/E2nCQuDfce/2014-03-20JD.html
http://www.4shared.com/mp3/-f42Lde0ba/2014-03-20JD.html
http://www.4shared.com/mp3/bHOjGU4Iba/2014-03-20JD.html
http://www.4shared.com/mp3/Rf1TBUHHce/2014-03-20JD.html
http://www.4shared.com/mp3/MFMHEUEIce/2014-03-20JD.html
http://www.4shared.com/mp3/soRvPVl1ba/2014-03-20JD.html
http://www.4shared.com/mp3/DcpXlKI9ba/2014-03-20JD.html
http://www.4shared.com/mp3/gN_sd4Q7ce/2014-03-20JD.html
http://www.4shared.com/mp3/B-Rxqe8-ce/2014-03-20JD.html
http://www.4shared.com/mp3/ZQa2GTZsba/2014-03-20JD.html
http://www.4shared.com/mp3/Mp3hXnixce/2014-03-20JD.html
http://www.4shared.com/mp3/E6N3fleSce/2014-03-20JD.html
http://www.4shared.com/mp3/u5wTJQHJce/2014-03-20JD.html
http://www.4shared.com/mp3/FaV-j8f9ba/2014-03-20JD.html
http://www.4shared.com/mp3/66k74c1Oba/2014-03-20JD.html
http://www.4shared.com/mp3/fbp33dK4ce/2014-03-20JD.html
http://www.4shared.com/mp3/CcIFziobba/2014-03-20JD.html
http://www.4shared.com/mp3/rtiWzpcXce/2014-03-20JD.html
http://www.4shared.com/mp3/IbUE009hce/2014-03-20JD.html
http://www.4shared.com/mp3/h5xb7MMPba/2014-03-20JD.html
http://www.4shared.com/mp3/NZVV2isiba/2014-03-20JD.html
http://www.4shared.com/mp3/iIkHGH-sce/2014-03-20JD.html
http://www.4shared.com/mp3/etuPwIqGce/2014-03-20JD.html
http://www.4shared.com/mp3/qOuRb9alba/2014-03-20JD.html
http://www.4shared.com/mp3/oFTyNxS0ce/2014-03-20JD.html
http://www.4shared.com/mp3/EALbeP2lce/2014-03-20JD.html
http://www.4shared.com/mp3/Nki_NbMuba/2014-03-20JD.html
http://www.4shared.com/mp3/gkWc__M6ce/2014-03-20JD.html
http://www.4shared.com/mp3/4LrzrNmVce/2014-03-20JD.html
http://www.4shared.com/mp3/YxWa8F25ce/2014-03-20JD.html
http://www.4shared.com/mp3/nMDy3wSOba/2014-03-20JD.html
http://www.4shared.com/mp3/rTL3qi0-ce/2014-03-20JD.html
http://www.4shared.com/mp3/84tHmH-nba/2014-03-20JD.html
http://www.4shared.com/mp3/dl2E9_n6ba/2014-03-20JD.html
http://www.4shared.com/mp3/Vm_UY-rNce/2014-03-20JD.html
http://www.4shared.com/mp3/Z6FzNKSece/2014-03-20JD.html
http://www.4shared.com/mp3/FiB6AYuHce/2014-03-20JD.html
http://www.4shared.com/mp3/CMhKeo_Bba/2014-03-20JD.html
http://www.4shared.com/mp3/bAW9oVvUce/2014-03-20JD.html
http://www.4shared.com/mp3/XQHYo7sUce/2014-03-20JD.html
http://www.4shared.com/mp3/1BX46EuPce/2014-03-20JD.html
http://www.4shared.com/mp3/8f-xInCtce/2014-03-20JD.html
http://www.pinterest.com/pin/332140541241032180/
http://www.pinterest.com/pin/332140541241032178/
http://www.pinterest.com/pin/332140541241032176/
http://www.pinterest.com/pin/332140541241032175/
http://www.pinterest.com/pin/332140541241032174/
http://www.pinterest.com/pin/332140541241032173/
http://www.pinterest.com/pin/332140541241032171/
http://www.pinterest.com/pin/332140541241032170/
http://www.pinterest.com/pin/332140541241032169/
http://www.pinterest.com/pin/332140541241032167/
http://www.pinterest.com/pin/332140541241032166/
http://www.pinterest.com/pin/332140541241032165/
http://www.pinterest.com/pin/332140541241032163/
http://www.pinterest.com/pin/332140541241032161/
http://www.pinterest.com/pin/332140541241032160/
http://www.pinterest.com/pin/332140541241032159/
http://www.pinterest.com/pin/332140541241032158/
http://www.pinterest.com/pin/332140541241032157/
http://www.pinterest.com/pin/332140541241032155/
http://www.pinterest.com/pin/332140541241032152/
http://www.pinterest.com/pin/332140541241032151/
http://www.pinterest.com/pin/332140541241032149/
http://www.pinterest.com/pin/332140541241032147/
http://www.pinterest.com/pin/332140541241032141/
http://www.pinterest.com/pin/332140541241032136/
http://www.pinterest.com/pin/332140541241032132/
http://www.pinterest.com/pin/332140541241032131/
http://www.pinterest.com/pin/332140541241032103/
http://www.pinterest.com/pin/332140541241032102/
http://www.pinterest.com/pin/332140541241032101/
http://www.pinterest.com/pin/332140541241032100/
http://www.pinterest.com/pin/332140541241032097/
http://www.pinterest.com/pin/332140541241032096/
http://www.pinterest.com/pin/332140541241032095/
http://www.pinterest.com/pin/332140541241032094/
http://www.pinterest.com/pin/332140541241032093/
http://www.pinterest.com/pin/332140541241032092/
http://www.pinterest.com/pin/332140541241032091/
http://www.pinterest.com/pin/332140541241032090/
http://www.pinterest.com/pin/332140541241032089/
http://www.pinterest.com/pin/332140541241032088/
http://www.pinterest.com/pin/332140541241032085/
http://www.pinterest.com/pin/332140541241032083/
http://www.pinterest.com/pin/332140541241032081/
http://www.pinterest.com/pin/332140541241032079/
http://www.pinterest.com/pin/332140541241032077/
http://www.pinterest.com/pin/332140541241032072/
http://www.pinterest.com/pin/332140541241032068/
http://www.pinterest.com/pin/332140541241032065/
http://www.pinterest.com/pin/332140541241032063/
http://www.pinterest.com/pin/332140541241032061/
http://www.pinterest.com/pin/332140541241032059/
http://www.pinterest.com/pin/332140541241032056/
http://www.pinterest.com/pin/332140541241032055/
http://www.pinterest.com/pin/332140541241032053/
http://www.pinterest.com/pin/332140541241032050/
http://www.pinterest.com/pin/332140541241032049/
来源:oschina
链接:https://my.oschina.net/u/1474559/blog/211568