mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
[Kotlin/en] correct object clarification (#2413)
* Kotlin: correct object clarification * Kotlin: correct object clarification
This commit is contained in:
parent
6977b86db7
commit
2fa414912e
@ -337,7 +337,7 @@ enum class EnumExample {
|
||||
|
||||
/*
|
||||
The "object" keyword can be used to create singleton objects.
|
||||
We cannot assign it to a variable, but we can refer to it by its name.
|
||||
We cannot instantiate it but we can refer to its unique instance by its name.
|
||||
This is similar to Scala singleton objects.
|
||||
*/
|
||||
object ObjectExample {
|
||||
@ -346,6 +346,11 @@ object ObjectExample {
|
||||
}
|
||||
}
|
||||
|
||||
fun useObject() {
|
||||
ObjectExample.hello()
|
||||
val someRef: Any = ObjectExample // we use objects name just as is
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Further Reading
|
||||
|
Loading…
Reference in New Issue
Block a user