Skip to content

cotrVarNullable

Creates a nullable variable

Aliases:

  • cotrVarNullable
  • variableNullable
  • nullableVariable

cpp

std::optional<Type> myVar =3;

csharp

Type? myVar =3;

dart

Type? myVar =3;

go

var myVar *Type =3

haskell

let myVar :: Maybe Type = Nothing

java

Type myVar = null;

javascript

let myVar = null;

javascriptreact

let myVar = null;

kotlin

var myVar: Type? = null

perl

mymyVar; # Variable can be undefined (undef).

php

Type?myVar =3;

powershell

Terminal window
myVar =null

python

my_var = None # Variable can be set to None.

rust

let my_var: Option<Type> =3;

scala

var myVar: Option[Type] = None

shellscript

Terminal window
# Bash doesn't have null, but you can use an empty string or a special value:
myVar=''

swift

var myVar: Type? =3

typescript

let myVar: Type | null =3;

typescriptreact

let myVar: Type | null =3;