Title here
Summary here
Go supports *constants* of character, string, boolean, and numeric values.
```kotlin
const val s: String = "constant"
fun main() {
println(s)
const val n = 500000000
val d = 3e20 / n
println(d)
println(d.toLong())
println(math.sin(n.toDouble()))
}
const
declares a constant value.
A const
statement can appear anywhere a var
statement can.
Constant expressions perform arithmetic with arbitrary precision.
A numeric constant has no type until it’s given one, such as by an explicit conversion.
A number can be given a type by using it in a context that requires one, such as a variable assignment or function call. For example, here math.sin
expects a Double
.
$ kotlinc constants.kt -include-runtime -d constants.jar
$ java -jar constants.jar
constant
6.0E11
600000000000
-0.28470407323754404
Next example: For.