Constant definition bounds an identifier with an immediate value (value aliasing).
// for global const
const <#identifier#> = <#immediate_value_expression#>
// or:
const <#identifier#>: <#type_expression#> = <#immediate_value_expression#>
let <#identifier#> = <#value_expression#>
// or:
let <#identifier#>: <#type_expression#> = <#value_expression#>
Global constant definition bounds an identifier with an immediate value.
const one = 1
const two = one + 1
const three = one + two
const four = two * 2
const message = "Hello World!\n"
public func main () -> Int32 {
printf("%s\n", message)
return 0
}
Local constant definition bounds an identifier with an value.
func mid (a: Int32, b: Int32) -> Int32 {
let sum = a + b
let result: Int32 = sum / 2
return result
}