opkspirit.blogg.se

Kotlin any example
Kotlin any example







kotlin any example / /// Create an RDS DB instance with a particular set of properties.

In this Kotlin Tutorial, we learned what a Kotlin with function is, and how to use this to create a scope (with-block) for an object (receiver) and access its members and functions. Find the complete example and learn how to set up and run in the AWS Code Examples Repository. Now, let us return length of the receiver object str from the with-block. In the following example, we will return lowercase value of the String from with-block. Just place the return value as the last statement in the with-block. Output Hello World! Return Value from With-Block To access receiver itself in the with-block, use this keyword. However, this approach does mean that you can use type-safe accessors. Inside the with-block, we have accessed length property and called uppercase() function of the receiver object str, with actually referencing the object str again like str.length or str.uppercase(). For example, this includes any configurations you might define in your own build script. Thanks to the fact that sequences do processing.

kotlin any example

In the following example, we will pass a String value for receiver object to with() and access the properties and functions of the String in the block. Examples of such operations are first, find, take, any, all, none or indexOf.









Kotlin any example