Syntax

Kotlin Object Singleton Syntax

In Kotlin, object singleton: declares a single instance — object Config { val version = 1 }

Quick Answer

Syntax
object Config { val version = 1 }
KotlinSyntax

Object Singleton

Code example
object Config { val version = 1 }

Declares a single instance.

Learn More

How to object singleton in Kotlin

  1. Open your Kotlin file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Kotlin Object Singleton Syntax

Use object Config { val version = 1 }.

Related Syntax References

Frequently asked questions

What is the Kotlin syntax for object singleton?

Use this pattern: object Config { val version = 1 }

Can I copy this Kotlin code example?

Yes. Use Copy code and adapt the example to your program.

Is this Kotlin syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify