Defining a constant: let or const

Hi everyone!
Swift uses ‘let’ to define a constant (afaik), FileMaker uses ‘let’ to define variables in formulars…

I‘m interrestet in what you guys think what keyword for defining a constant is the bettet one: let or const. And why.

in other basic let was used to assign values to a variable with the same type.
constant translated to german have a better meaning.

const s as string = “Hello”
var s as string = “Hello”
set s = constant

1 Like

Of the languages I’m familiar with, const is more common. I do prefer it because it is pretty clear.

Keyword Languages Thoughts
const VB, C#, Xojo, Objective-C, JavaScript :+1:
val Kotlin Easy to confuse with var
let Swift This makes no sense to me. It’s too vague.
final Java Not bad, I suppose.
n/a Python Not having constants is just weird.

Thanks Markus and Paul!

Swift’s let is not actually a constant. It’s really a variable that is not changeable after it is assigned a value.

True (and same with Kotlin val). The nice thing about this is you can assign a function result to it. Although they are technically not constants, they are what you use if you want similar behavior.

let /let/ verb

  1. not prevent or forbid; allow.
  2. used in the imperative as a polite way of making or responding to a suggestion, giving an instruction, or introducing a remark.

This is BASIC, not INTERCAL. The compiler will use Const and like it. :yum:

english … one word and hundreds meanings and usually only understandable in a set of words or context.

1 Like

Technically Kotlin constants are not “val” but the verbose combination “const val”.