{"id":286399,"date":"2017-05-16T11:20:04","date_gmt":"2017-05-16T07:20:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286399"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286399","title":{"rendered":"\u0418\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u0439 Kotlin, \u043d\u0430\u0431\u043e\u0440 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/d7c\/41f\/bb5\/d7c41fbb554644e0be8f303b554d6a2a.png\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 <i>Kotlin<\/i>, \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 <i>Java<\/i>. \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 \u043b\u0443\u0447\u0448\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0438\u0437 <i>Kotlin<\/i>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 <i>Kotlin<\/i>.<\/p>\n<p>  <a name=\"habracut\"><\/a><br \/>  <i>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u0439 <i>Kotlin<\/i>. \u0412\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0430\u0432\u0442\u043e\u0440 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 <i>Kotlin<\/i> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/i><\/p>\n<blockquote><p>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 \u043c\u043e\u0435 \u0441\u043a\u0440\u043e\u043c\u043d\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0438\u0447\u0438 \u044f\u0437\u044b\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u0441\u043e\u0431\u043e\u0439 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u0440\u0438 \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0438, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u043c\u0435\u043d\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u0432 \u043e\u0434\u043d\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435. <br \/>  <i>Philipp Hauer<\/i><\/p><\/blockquote>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 Kotlin \u0441 \u043e\u0431\u0449\u0438\u043c\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u043c\u0438 \u0438 \u0438\u0434\u0438\u043e\u043c\u0430\u043c\u0438 Java.<\/h2>\n<p>  \u0412 <i>Java<\/i> \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 (boilerplate code) \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0438 \u0438\u0434\u0438\u043e\u043c. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0438\u043c\u0435\u044e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043f\u0440\u044f\u043c\u043e \u0432 \u044f\u0437\u044b\u043a\u0435 <i>Kotlin<\/i> \u0438\u043b\u0438 \u0432 \u0435\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435:<\/p>\n<table>\n<tr>\n<th><i>Java<\/i> \u0438\u0434\u0438\u043e\u043c\u044b \u0438\u043b\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/th>\n<th>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 <i>Kotlin<\/i><\/th>\n<\/tr>\n<tr>\n<td>Optional<\/td>\n<td>Nullable-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/td>\n<\/tr>\n<tr>\n<td>\u0413\u0435\u0442\u0442\u0435\u0440\u044b, \u0441\u0435\u0442\u0442\u0435\u0440\u044b, <i>Backing field<\/i><\/td>\n<td>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (properties)<\/td>\n<\/tr>\n<tr>\n<td>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0443\u0442\u0438\u043b\u0438\u0442<\/td>\n<td>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/td>\n<\/tr>\n<tr>\n<td>\u041d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c (Immutability), \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (Value Objects)<\/td>\n<td><code>data class<\/code> \u0441 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438, <code>copy()<\/code><\/td>\n<\/tr>\n<tr>\n<td>Fluent Setter (Wither) <\/td>\n<td>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, <code>apply()<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (Method Chaining)<\/td>\n<td>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/td>\n<\/tr>\n<tr>\n<td>\u0421\u0438\u043d\u0433\u043b\u0442\u043e\u043d (Singleton)<\/td>\n<td><code>object<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u0414\u0435\u043b\u0435\u0442\u0430\u0433\u044b (Delegation)<\/td>\n<td>\u0414\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>by<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u041b\u0435\u043d\u0438\u0432\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f (\u043f\u043e\u0442\u043e\u043a\u043e-\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f) <\/td>\n<td>\u0414\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>by: lazy()<\/code> <\/td>\n<\/tr>\n<tr>\n<td>\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c (Observer)<\/td>\n<td> \u0414\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>by: Delegates.observable()<\/code><\/td>\n<\/tr>\n<\/table>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  \u0421\u0440\u0435\u0434\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u0447\u0442\u043e \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434:<br \/>   \u2014 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043d\u044b\u043c \u043e\u0448\u0438\u0431\u043a\u0430\u043c<br \/>   \u2014 \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u0438\u043c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f<br \/>   \u2014 \u043f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c<br \/>   \u2014 \u043f\u043e\u0442\u043e\u043a\u043e-\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c<\/p>\n<p>  \u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 <i>Java 8<\/i>, \u0443 <i>Kotlin<\/i> \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<br \/>   \u2014 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c, <code>val<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 <code>data classes<\/code>, <code>copy()<\/code><br \/>   \u2014 \u0432\u0441\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: <code>if<\/code>, <code>when<\/code> \u0438 <code>try-catch<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u041c\u043e\u0436\u043d\u043e \u0438\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438. <br \/>   \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u0442\u0438\u043f\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430<br \/>   \u2014 \u043a\u0440\u0430\u0442\u043a\u0438\u0435 \u043b\u044f\u043c\u0431\u0434\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<br \/>   \u2014 Kotlin API \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 <\/p>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u043c, \u043a\u0440\u0430\u0442\u043a\u043e\u043c \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0432\u0438\u0434\u0435. \u0418 \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0438\u0441\u0442\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0431\u0435\u0437 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432) \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435. <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439: <\/h2>\n<p>  <\/p>\n<pre><code>\/\/ Don't fun getDefaultLocale(deliveryArea: String): Locale {     val deliverAreaLower = deliveryArea.toLowerCase()     if (deliverAreaLower == &quot;germany&quot; || deliverAreaLower == &quot;austria&quot;) {         return Locale.GERMAN     }     if (deliverAreaLower == &quot;usa&quot; || deliverAreaLower == &quot;great britain&quot;) {         return Locale.ENGLISH     }     if (deliverAreaLower == &quot;france&quot;) {         return Locale.FRENCH     }     return Locale.ENGLISH } <\/code><\/pre>\n<pre><code>\/\/ Do fun getDefaultLocale2(deliveryArea: String) = when (deliveryArea.toLowerCase()) {     &quot;germany&quot;, &quot;austria&quot; -&gt; Locale.GERMAN     &quot;usa&quot;, &quot;great britain&quot; -&gt; Locale.ENGLISH     &quot;france&quot; -&gt; Locale.FRENCH     else -&gt; Locale.ENGLISH } <\/code><\/pre>\n<p>  \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e: \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 <code>if<\/code> \u0438\u043c\u0435\u0439\u0442\u0435 \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>when<\/code>.<\/p>\n<p>  <code>try-catch<\/code> \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code>val json = &quot;&quot;&quot;{&quot;message&quot;:&quot;HELLO&quot;}&quot;&quot;&quot; val message = try {     JSONObject(json).getString(&quot;message&quot;) } catch (ex: JSONException) {     json } <\/code><\/pre>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>  \u0412 <i>Java<\/i> \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043b\u044f \u0443\u0442\u0438\u043b\u0438\u0442. \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u0432 <i>Kotlin<\/i> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>\/\/Don't object StringUtil {     fun countAmountOfX(string: String): Int{         return string.length - string.replace(&quot;x&quot;, &quot;&quot;).length     } } StringUtil.countAmountOfX(&quot;xFunxWithxKotlinx&quot;) <\/code><\/pre>\n<p>  <i>Kotlin<\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f. \u0427\u0430\u0441\u0442\u043e, \u043c\u044b \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0422\u0430\u043a, \u043d\u0430\u0448 \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043d\u0430 \u00ab\u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u0438\u0441\u0442\u043e\u0440\u0438\u0438\u00bb.<\/p>\n<pre><code>\/\/Do fun String.countAmountOfX(): Int {     return length - replace(&quot;x&quot;, &quot;&quot;).length } &quot;xFunxWithxKotlinx&quot;.countAmountOfX()  <\/code><\/pre>\n<h2>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u043c\u0435\u0441\u0442\u043e <i>Fluent Setter<\/i>.<\/h2>\n<p>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u0432 <i>Java<\/i>, <i>fluent setters<\/i> (\u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u00abWither\u00bb) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043d\u044b\u043c \u043e\u0448\u0438\u0431\u043a\u0430\u043c:  <\/p>\n<pre><code>\/\/Don't val config = SearchConfig()        .setRoot(&quot;~\/folder&quot;)        .setTerm(&quot;kotlin&quot;)        .setRecursive(true)        .setFollowSymlinks(true) <\/code><\/pre>\n<p>  \u0412 <i>Kotlin<\/i> \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043b\u0443\u0436\u0430\u0442 \u0434\u043b\u044f \u0442\u043e\u0439 \u0436\u0435 \u0446\u0435\u043b\u0438, \u043d\u043e \u0432 \u044d\u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0441\u0430\u043c \u044f\u0437\u044b\u043a:<\/p>\n<pre><code>\/\/Do val config2 = SearchConfig2(        root = &quot;~\/folder&quot;,        term = &quot;kotlin&quot;,        recursive = true,        followSymlinks = true ) <\/code><\/pre>\n<h2><code>apply()<\/code> \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430<\/h2>\n<p>  <\/p>\n<pre><code>\/\/Don't val dataSource = BasicDataSource() dataSource.driverClassName = &quot;com.mysql.jdbc.Driver&quot; dataSource.url = &quot;jdbc:mysql:\/\/domain:3309\/db&quot; dataSource.username = &quot;username&quot; dataSource.password = &quot;password&quot; dataSource.maxTotal = 40 dataSource.maxIdle = 40 dataSource.minIdle = 4 <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>apply()<\/code> \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430. <\/p>\n<pre><code>\/\/Do val dataSource = BasicDataSource().apply {     driverClassName = &quot;com.mysql.jdbc.Driver&quot;     url = &quot;jdbc:mysql:\/\/domain:3309\/db&quot;     username = &quot;username&quot;     password = &quot;password&quot;     maxTotal = 40     maxIdle = 40     minIdle = 4 } <\/code><\/pre>\n<p>  <code>apply()<\/code> \u0442\u0430\u043a \u0436\u0435 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0448\u044c \u0441 <i>Java<\/i> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0438\u0437 <i>Kotlin<\/i>. <\/p>\n<h2>\u041d\u0435 \u043d\u0443\u0436\u043d\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h2>\n<p>  \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u00abmethod chaining\u00bb \u0438\u043b\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u00abconstructor chaining\u00bb)<\/p>\n<pre><code>\/\/Don't fun find(name: String){     find(name, true) } fun find(name: String, recursive: Boolean){ } <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u043e \u043a\u043e\u0441\u0442\u044b\u043b\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u0432 <i>Kotlin<\/i> \u0435\u0441\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code>\/\/Do fun (name: String, recursive: Boolean = true){ } <\/code><\/pre>\n<p>  \u041f\u043e \u0444\u0430\u043a\u0442\u0443, \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430, \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. <\/p>\n<h2>\u041a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u044c \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0441 <i>Nullability<\/i> <\/h2>\n<p>  <\/p>\n<h3>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 <code>if-null<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/h3>\n<p>  <i>Java<\/i> \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 <code>null<\/code> \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0439 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<pre><code>\/\/Don't if (order == null || order.customer == null || order.customer.address == null){     throw IllegalArgumentException(&quot;Invalid Order&quot;) } val city = order.customer.address.city <\/code><\/pre>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u0430\u043a \u0432\u044b \u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 <code>null<\/code>, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435\u0441\u044c. <i>Kotlin<\/i> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>?.<\/code> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u00ab\u044d\u043b\u0432\u0438\u0441\u00bb <code>?:<\/code> <\/p>\n<pre><code>\/\/Do val city = order?.customer?.address?.city ?: throw IllegalArgumentException(&quot;Invalid Order&quot;) <\/code><\/pre>\n<h3>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0442\u0438\u043f\u043e\u0432<\/h3>\n<p>  \u0412\u0441\u0435 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0442\u0430\u043a \u0436\u0435 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0442\u0438\u043f\u043e\u0432:<\/p>\n<pre><code>\/\/Don't if (service !is CustomerService) {     throw IllegalArgumentException(&quot;No CustomerService&quot;) } service.getCustomer() <\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>as?<\/code> \u0438 <code>?:<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0438\u043f, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 (smart cast) \u0438\u043b\u0438 \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0442\u0438\u043f \u043d\u0435 \u0442\u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c. \u0412\u0441\u0435 \u0432 \u043e\u0434\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435!<\/p>\n<pre><code>\/\/Do service as? CustomerService ?: throw IllegalArgumentException(&quot;No CustomerService&quot;) service.getCustomer() <\/code><\/pre>\n<h3>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>!!<\/code><\/h3>\n<p>  <\/p>\n<pre><code>\/\/Don't order!!.customer!!.address!!.city <\/code><\/pre>\n<blockquote><p>\u041d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0432\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e <code>!!<\/code> \u0441\u043c\u043e\u0442\u0440\u044f\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0433\u0440\u0443\u0431\u043e. \u042d\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043a\u0430\u043a \u0432\u044b \u043a\u0440\u0438\u0447\u0438\u0442\u0435 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0422\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u044f\u0437\u044b\u043a\u0430 <i>Kotlin<\/i> \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0432\u0430\u0441 \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u043e\u0434\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c.<br \/>  <i> \u00abKotlin in Action\u00bb, \u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0416\u0435\u043c\u0435\u0440\u043e\u0432 \u0438 \u0421\u0432\u0435\u0442\u043b\u0430\u043d\u0430 \u0418\u0441\u0430\u043a\u043e\u0432\u0430.<\/i><\/p><\/blockquote>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>let()<\/code><\/h3>\n<p>  \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 <code>let()<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <code>if<\/code>. \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0441\u044f \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0443 \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>let()<\/code>.<\/p>\n<pre><code>val order: Order? = findOrder() if (order != null){     dun(order.customer) } <\/code><\/pre>\n<p>  \u0421 <code>let()<\/code> \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u043d\u0438\u043a\u0430\u043a\u0430\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u043e\u0434\u043d\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code>findOrder()?.let { dun(it.customer) } \/\/or findOrder()?.customer?.let(::dun) <\/code><\/pre>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/h2>\n<p>  \u0421 <code>data classes<\/code> \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445.<\/p>\n<pre><code>\/\/Don't fun send(target: String){} <\/code><\/pre>\n<pre><code>\/\/Do fun send(target: EmailAddress){} \/\/ expressive, readable, type-safe  data class EmailAddress(val value: String) <\/code><\/pre>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<pre><code>\/\/ Don't fun mapToDTO(entity: SnippetEntity): SnippetDTO {     val dto = SnippetDTO(             code = entity.code,             date = entity.date,             author = &quot;${entity.author.firstName} ${entity.author.lastName}&quot;     )     return dto } <\/code><\/pre>\n<p>  \u0421 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u043c\u0438 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e, \u043a\u043e\u0440\u043e\u0442\u043a\u043e \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438:<\/p>\n<pre><code>\/\/ Do fun mapToDTO(entity: SnippetEntity) = SnippetDTO(         code = entity.code,         date = entity.date,         author = &quot;${entity.author.firstName} ${entity.author.lastName}&quot; ) val dto = mapToDTO(entity) <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u0445, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0442\u043a\u0438\u043c \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0412 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u044b \u043d\u0435 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439.<\/p>\n<pre><code>\/\/ Do fun SnippetEntity.toDTO() = SnippetDTO(         code = code,         date = date,         author = &quot;${author.firstName} ${author.lastName}&quot; ) val dto = entity.toDTO() <\/code><\/pre>\n<h2>\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432. <\/h2>\n<p>  \u0414\u0432\u0430\u0436\u0434\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (init \u0431\u043b\u043e\u043a) \u0432 \u0442\u0435\u043b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. <\/p>\n<pre><code>\/\/ Don't class UsersClient(baseUrl: String, appName: String) {     private val usersUrl: String     private val httpClient: HttpClient     init {         usersUrl = &quot;$baseUrl\/users&quot;         val builder = HttpClientBuilder.create()         builder.setUserAgent(appName)         builder.setConnectionTimeToLive(10, TimeUnit.SECONDS)         httpClient = builder.build()     }     fun getUsers(){         \/\/call service using httpClient and usersUrl     } } <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 <code>init<\/code> \u0431\u043b\u043e\u043a\u0435). <code>apply()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043c\u043e\u0447\u044c \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043e\u0434\u043d\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c. <\/p>\n<pre><code>\/\/ Do class UsersClient(baseUrl: String, appName: String) {     private val usersUrl = &quot;$baseUrl\/users&quot;     private val httpClient = HttpClientBuilder.create().apply {         setUserAgent(appName)         setConnectionTimeToLive(10, TimeUnit.SECONDS)     }.build()     fun getUsers(){         \/\/call service using httpClient and usersUrl     } }  <\/code><\/pre>\n<h2><code>object<\/code> \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0431\u0435\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/h2>\n<p>  <code>object<\/code> \u0438\u0437 <i>Kotlin<\/i> \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <i>Converter<\/i> \u0438\u0437 <i>Vaadin 8<\/i>.<\/p>\n<pre><code>\/\/Do object StringToInstantConverter : Converter&lt;String, Instant&gt; {     private val DATE_FORMATTER = DateTimeFormatter.ofPattern(&quot;dd.MM.yyyy HH:mm:ss Z&quot;)             .withLocale(Locale.UK)             .withZone(ZoneOffset.UTC)      override fun convertToModel(value: String?, context: ValueContext?) = try {         Result.ok(Instant.from(DATE_FORMATTER.parse(value)))     } catch (ex: DateTimeParseException) {         Result.error&lt;Instant&gt;(ex.message)     }      override fun convertToPresentation(value: Instant?, context: ValueContext?) =             DATE_FORMATTER.format(value) } <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 <a href=\"https:\/\/blog.philipphauer.de\/kotlin-practice-spring-boot-vaadin\/\">Kotlin, Spring Boot \u0438 Vaadin \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442<\/a><\/p>\n<h2>Destructing<\/h2>\n<p>  \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b destructuring \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 <code>data class<\/code> (\u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0439), \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Pair<\/code> (\u0447\u0442\u043e \u043c\u0435\u043d\u0435\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043f\u0430\u0440\u0430 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443)<\/p>\n<pre><code>\/\/Do data class ServiceConfig(val host: String, val port: Int) fun createServiceConfig(): ServiceConfig {     return ServiceConfig(&quot;api.domain.io&quot;, 9389) } \/\/destructuring in action: val (host, port) = createServiceConfig() <\/code><\/pre>\n<p>  \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, destructuring \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0434\u043e\u0431\u0435\u043d \u0438 \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 <code>map<\/code>:<\/p>\n<pre><code>\/\/Do val map = mapOf(&quot;api.domain.io&quot; to 9389, &quot;localhost&quot; to 8080) for ((host, port) in map){     \/\/... } <\/code><\/pre>\n<h2>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440<\/h2>\n<p>  <code>listOf<\/code>, <code>mapOf<\/code>, \u0438 \u0438\u043d\u0444\u0438\u043a\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>to<\/code> \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 (\u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <i>JSON<\/i>). \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0442\u0430\u043a \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e \u043a\u0430\u043a \u0432 <i>Python<\/i> \u0438 <i>JavaScript<\/i>, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u0432 Java.<\/p>\n<p>  <i>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0410\u043d\u0434\u0440\u0435\u0439 \u0411\u0440\u0435\u0441\u043b\u0430\u0432 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430 Jpoint 2017 \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043e\u043d\u0438 \u0434\u0443\u043c\u0430\u044e\u0442 \u043d\u0430\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0434\u0435\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u043e\u0437\u0440\u0438\u043c\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c<\/i><\/p>\n<pre><code>\/\/Do val customer = mapOf(         &quot;name&quot; to &quot;Clair Grube&quot;,         &quot;age&quot; to 30,         &quot;languages&quot; to listOf(&quot;german&quot;, &quot;english&quot;),         &quot;address&quot; to mapOf(                 &quot;city&quot; to &quot;Leipzig&quot;,                 &quot;street&quot; to &quot;Karl-Liebknecht-Stra\u00dfe 1&quot;,                 &quot;zipCode&quot; to &quot;04107&quot;         ) ) <\/code><\/pre>\n<p>  \u041f\u0440\u0430\u0432\u0434\u0430, \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>data class<\/code> \u0438\u043b\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f JSON. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445), \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u0430. <\/p>\n<h2>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/h2>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u043c\u043e\u0435\u043c GitHub \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <a href=\"https:\/\/github.com\/phauer\/blog-related\/tree\/master\/kotlin-idiomatic\"> idiomatic kotlin<\/a><\/p>\n<p>  <i>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c. \u0411\u0443\u0434\u0443 \u0432\u0435\u0441\u044c\u043c\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0432\u0441\u0435\u043c \u0442\u0435\u043c, \u043a\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u0442 \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0435. <br \/>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/i><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/328218\/\"> https:\/\/habrahabr.ru\/post\/328218\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/d7c\/41f\/bb5\/d7c41fbb554644e0be8f303b554d6a2a.png\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 <i>Kotlin<\/i>, \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 <i>Java<\/i>. \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 \u043b\u0443\u0447\u0448\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0438\u0437 <i>Kotlin<\/i>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 <i>Kotlin<\/i>.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-286399","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286399"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286399\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}