@@ -331,7 +331,7 @@ For example, the [`.toString()`](https://kotlinlang.org/api/latest/jvm/stdlib/ko
331
331
can be called on a nullable receiver. When invoked on a ` null ` value, it safely returns the string ` "null" ` without throwing an exception:
332
332
333
333
``` kotlin
334
- // SampleStart
334
+ // sampleStart
335
335
fun main () {
336
336
// Assigns null to a nullable Person object stored in the person variable
337
337
val person: Person ? = null
@@ -343,7 +343,7 @@ fun main() {
343
343
344
344
// Defines a simple Person class
345
345
data class Person (val name : String )
346
- // SampleEnd
346
+ // sampleEnd
347
347
```
348
348
{kotlin-runnable="true"}
349
349
@@ -353,7 +353,7 @@ If you expect the `.toString()` function to return a nullable string (either a s
353
353
The ` ?. ` operator calls ` .toString() ` only if the object is not ` null ` , otherwise it returns ` null ` :
354
354
355
355
``` kotlin
356
- // SampleStart
356
+ // sampleStart
357
357
fun main () {
358
358
// Assigns a nullable Person object to a variable
359
359
val person1: Person ? = null
@@ -368,7 +368,7 @@ fun main() {
368
368
369
369
// Defines a Person class
370
370
data class Person (val name : String )
371
- // SampleEnd
371
+ // sampleEnd
372
372
```
373
373
{kotlin-runnable="true"}
374
374
@@ -407,7 +407,7 @@ You can use the `as?` operator for safe casts. It tries to cast a value to the s
407
407
408
408
``` kotlin
409
409
fun main () {
410
- // SampleStart
410
+ // sampleStart
411
411
// Declares a variable of type Any, which can hold any type of value
412
412
val a: Any = " Hello, Kotlin!"
413
413
@@ -420,7 +420,7 @@ fun main() {
420
420
// null
421
421
println (aString)
422
422
// "Hello, Kotlin!"
423
- // SampleEnd
423
+ // sampleEnd
424
424
}
425
425
```
426
426
{kotlin-runnable="true"}
@@ -435,7 +435,7 @@ the `filterNotNull()` function:
435
435
436
436
``` kotlin
437
437
fun main () {
438
- // SampleStart
438
+ // sampleStart
439
439
// Declares a list containing some null and non-null integer values
440
440
val nullableList: List <Int ?> = listOf (1 , 2 , null , 4 )
441
441
@@ -444,7 +444,7 @@ fun main() {
444
444
445
445
println (intList)
446
446
// [1, 2, 4]
447
- // SampleEnd
447
+ // sampleEnd
448
448
}
449
449
```
450
450
{kotlin-runnable="true"}
0 commit comments