Skip to content

cotrConst

Creates a constant variable

Aliases:

  • cotrConst
  • constant
  • cotrVal

cpp

const type myConst = value;

csharp

const Type myConst = value;

dart

const myConst =2;

go

const variableName variableType = variableValue

haskell

-- Haskell does not have a 'const' keyword. Use 'let' for immutable values.

java

final Type myConst = value;

javascript

const myConst =2;

javascriptreact

const myConst =2;

kotlin

val myConst =2

perl

use constant MY_CONST =>2;

php

constmyConst =2;

powershell

Terminal window
myConst =2

python

MY_CONST = value

r

MY_CONST <-2

ruby

MY_CONST =2

rust

const myConst: type =3;

scala

val myConst =2

shellscript

Terminal window
# Bash uses readonly variables for constants:
readonly myConst=value

swift

let myConst =2;

typescript

const myConst =2;

typescriptreact

const myConst =2;