{"id":183444,"date":"2013-06-15T22:45:03","date_gmt":"2013-06-15T18:45:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=183444"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=183444","title":{"rendered":"<span class=\"post_title\">Kotlin M5.3: Delegated Properties \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u043c\u044b \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043c\u0430\u0439\u043b\u0441\u0442\u043e\u0443\u043d \u044f\u0437\u0432\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438 <a href=\"http:\/\/kotlin.jetbrains.com\">Kotlin<\/a>, M5.3.<br \/>  \u0412 \u044d\u0442\u043e\u0442 \u0440\u0435\u043b\u0438\u0437 \u0432\u043e\u0448\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439: \u043e\u0442 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u0432 \u0434\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u044f\u0437\u044b\u043a\u0435.<br \/>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435: \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 (delegated properties).<a name=\"habracut\"><\/a><\/p>\n<p>  \u041c\u043d\u043e\u0433\u0438\u043c \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u044f\u0437\u044b\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b  <\/p>\n<ul>\n<li>\u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (lazy properties): \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438;<\/li>\n<li>\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f (observable properties);<\/li>\n<li>\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435 \u0432 Map&#8217;\u0435, \u0430 \u043d\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044f\u0445;<\/li>\n<li>&lt;\u0435\u0449\u0435 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043a\u0440\u0443\u0442\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430&gt;&#8230;<\/li>\n<\/ul>\n<p>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0435\u043c \u044d\u0442\u0438\u043c \u043b\u044e\u0434\u044f\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043c\u043e\u043b, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u0442\u0435, \u0430 \u0436\u0438\u0437\u043d\u044c, \u043c\u043e\u043b, \u0442\u044f\u0436\u0435\u043b\u0430\u2026 \u0414\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442: \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0438\u0434 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u044f\u0437\u044b\u043a\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c\u2026 \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043d\u0435 \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430: \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0430\u0432\u0435\u0432\u0430\u044e\u0442 \u0443\u043d\u044b\u043d\u0438\u0435, \u0430 \u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0432 \u044f\u0437\u044b\u043a\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u044e\u0442 \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u0422\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u043f\u0443\u0442\u044c: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u0432\u0438\u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0432 \u044f\u0437\u044b\u043a\u0435.<\/p>\n<h3>\u0414\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/h3>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code>class Example {   var p: String by Delegate() } <\/code><\/pre>\n<p>  \u041f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441: \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043b\u0435 \u0442\u0438\u043f\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u00abby &lt;\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435&gt;\u00bb. \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u00abby\u00bb \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <i>\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c<\/i>: \u0432\u044b\u0437\u043e\u0432\u044b \u0433\u0435\u0442\u0442\u0435\u0440\u0430 \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041c\u044b \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 get() \u0438 set() \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439:<\/p>\n<pre><code>class Delegate() {   fun get(thisRef: Any?, prop: PropertyMetadata): String {     return &quot;$thisRef, thank you for delegating '${prop.name}' to me!&quot;   }    fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {     println(&quot;$value has been assigned&quot;)   } } <\/code><\/pre>\n<p>  (\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0443\u0433\u0430\u0435\u0442, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041d\u0435 \u0431\u043e\u0439\u0442\u0435\u0441\u044c, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0442\u0430\u043a \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u0435\u0435, <a href=\"https:\/\/github.com\/JetBrains\/kotlin\/blob\/build-0.5.742\/libraries\/stdlib\/src\/kotlin\/properties\/Delegation.kt#L3\">\u0432\u043e\u0442 \u043e\u043d<\/a>, \u0434\u0430\u0436\u0435 \u0434\u0432\u0430 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 \ud83d\ude42 )<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0447\u0438\u0442\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 p, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f get() \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 Delegate, \u043f\u0440\u0438\u0447\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0430 \u0432\u0442\u043e\u0440\u044b\u043c \u2014 \u043e\u0431\u044a\u0435\u043a\u0442-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 p (\u0443 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430):<\/p>\n<pre><code>val e = Example() println(e.p) <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u00abExample@33a17727, thank you for delegating \u2018p\u2019 to me!\u00bb.<\/p>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f set(). \u0414\u0432\u0430 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u2014 \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0443 get(), \u0430 \u0442\u0440\u0435\u0442\u0438\u0439 \u2014 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code>e.p = &quot;NEW&quot; <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u00abNEW has been assigned to \u2018p\u2019 in Example@33a17727\u00bb.<\/p>\n<p>  \u0412\u044b, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043f\u0440.? \u041c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u0438, \u043d\u043e \u0431\u041e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 <a href=\"https:\/\/github.com\/JetBrains\/kotlin\/blob\/build-0.5.742\/libraries\/stdlib\/src\/kotlin\/properties\/Delegation.kt\">\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Kotlin<\/a>.<\/p>\n<p>  \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <a href=\"https:\/\/github.com\/JetBrains\/kotlin\/blob\/build-0.5.742\/libraries\/stdlib\/src\/kotlin\/properties\/Delegation.kt#L12\">kotlin.properties.Delegates<\/a>. <\/p>\n<h3>\u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/h3>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 lazy:<\/p>\n<pre><code>import kotlin.properties.Delegates  class LazySample {     val lazy: String by Delegates.lazy {         println(&quot;computed!&quot;)         &quot;Hello&quot;     } } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f Delegates.lazy() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442-\u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043b\u0435\u043d\u0438\u0432\u043e\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 get() \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u044f\u043c\u0431\u0434\u0430-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 lazy() \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435; \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0437\u0430\u043f\u043e\u043c\u043d\u0435\u043d\u043d\u043e\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 blockingLazy(): \u043e\u043d\u0430 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043e \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043e.<\/p>\n<h3>Observable \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/h3>\n<pre><code>class User {     var name: String by Delegates.observable(&quot;&lt;no name&gt;&quot;) {         d, old, new -&gt;         println(&quot;$old -&gt; $new&quot;)     } } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f observable() \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a (\u043b\u044f\u043c\u0431\u0434\u0430-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0438. \u0423 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0441\u0442\u0430\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e vetoable() \u0432\u043c\u0435\u0441\u0442\u043e observable().<\/p>\n<h3>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0431\u0435\u0437 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432<\/h3>\n<p>  \u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u0432: \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442 \u00ab\u043a\u0430\u043a \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c not-null \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0435\u0441\u043b\u0438 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c (\u044f \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u044e)?\u00bb. Kotlin \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0431\u0435\u0437 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432:<\/p>\n<pre><code>class Foo {   var bar: Bar \/\/ error: must be initialized } <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c null, \u0442\u043e \u0442\u043e\u0433\u0434\u0430 \u0442\u0438\u043f \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043d\u0435 Bar, \u0430 Bar?, \u0438 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438\u2026 \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c:<\/p>\n<pre><code>class Foo {   var bar: Bar by Delegates.notNull() } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f, \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0431\u0440\u043e\u0441\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u041f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 Map. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432 \u00ab\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u00bb \u043a\u043e\u0434\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 JSON:<\/p>\n<pre><code>class User(val map: Map&lt;String, Any?&gt;) {     val name: String by Delegates.mapVal(map)     val age: Int     by Delegates.mapVal(map) } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 map:<\/p>\n<pre><code>val user = User(mapOf(     &quot;name&quot; to &quot;John Doe&quot;,     &quot;age&quot;  to 25 )) <\/code><\/pre>\n<p>  \u0414\u0435\u043b\u0435\u0433\u0430\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0442\u043e\u043a\u043e\u0432\u044b\u043c \u043a\u043b\u044e\u0447\u0430\u043c \u2014 \u0438\u043c\u0435\u043d\u0430\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432:<\/p>\n<pre><code>println(user.name) \/\/ Prints &quot;John Doe&quot; println(user.age)  \/\/ Prints 25 <\/code><\/pre>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/JetBrains\/blog\/183444\/\"> http:\/\/habrahabr.ru\/company\/JetBrains\/blog\/183444\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u043c\u044b \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043c\u0430\u0439\u043b\u0441\u0442\u043e\u0443\u043d \u044f\u0437\u0432\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438 <a href=\"http:\/\/kotlin.jetbrains.com\">Kotlin<\/a>, M5.3.<br \/>  \u0412 \u044d\u0442\u043e\u0442 \u0440\u0435\u043b\u0438\u0437 \u0432\u043e\u0448\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439: \u043e\u0442 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u0432 \u0434\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u044f\u0437\u044b\u043a\u0435.<br \/>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435: \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 (delegated properties).<\/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-183444","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/183444","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=183444"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/183444\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=183444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=183444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=183444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}