Title here
Summary here
Go supports _constants_ of character, string, boolean, and numeric values.
`const` declares a constant value.
```ruby
S = "constant"
You can use constants anywhere you can use a variable.
N = 500000000
Constant expressions perform arithmetic with arbitrary precision.
D = 3e20 / N
puts D
A numeric constant has no type until it’s given one, such as by an explicit conversion.
puts D.to_i
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 Float
.
puts Math.sin(N)
To run the program, save the code in a file, for example, constants.rb
, and use Ruby to execute it.
$ ruby constants.rb
6e+11
600000000000
-0.28470407323754404
Constant support in Ruby provides a straightforward way to handle immutable values.