Skip to content

cotrTypeCheck

Gets the type of a variable

Aliases:

  • cotrTypeCheck
  • checkType
  • getType
  • typeOf

cpp

typeid(variable)

csharp

variable.GetType()

dart

variable.runtimeType

go

fmt.Printf("%T", variable)

haskell

variable :: Type

java

variable.getClass()

javascript

typeof variable

javascriptreact

typeof variable

kotlin

variable::class

perl

ref variable

php

gettype(variable)

powershell

Terminal window
variable.GetType()

python

type(variable)

r

class(variable)

ruby

variable.class

rust

variable.type()

scala

variable.getClass

shellscript

Terminal window
# Bash is dynamically typed, but you can use file or grep for basic checks:
file variable | grep -q 'type'

swift

type(of: variable)

typescript

typeof variable // Note: This checks the runtime type.

typescriptreact

typeof variable // Note: This checks the runtime type.