Constants and variables

  • varDeclare variables. Default isnullThe type is determined after the first assignment and cannot be changed.
  • You can usefinalorconstA modified constant
  • constA variable is a compile-time constant
  • finalVariables are initialized when first used (constIs implicitfinal)
  • Instance variables can befinalBut it can’t beconst
  • classLevel constants can be usedstatic constmodified

Built-in types

  • Numbernumeric
  • Stringstring
  • BooleanThe Boolean
  • ListThe list of
  • MapKey/value pair
  • RunesSymbol character
  • Symbolsidentifier

numeric

  • num
  • int
  • double
  • The operator
    • +
    • -
    • *
    • /
    • %Take more than
    • ~ /Results the integer
  • Commonly used attributes
    • isNaN
    • isEven
    • isOdd
  • Commonly used method
    • round()
    • floor()
    • ceil()
    • toInt()
    • toDouble()
    • abs()

string

  • 'and"Create create string
  • ' ' 'and"" "Creates a multi-line string
  • rCreate a raw string
  • String operator
    • +
    • *
    • = =
    • []
  • Interpolation expression
    • ${expression}
    • Ex. :print($expression)
  • Commonly used attributes
    • length
    • isEmpty
    • isNotEmpty
  • Commonly used method
    • contains()
    • subString()
    • startsWith() endsWith()
    • indexOf() lastIndexOf()
    • toLowerCase() toUpperCase()
    • trim() trimLeft() trimRight()
    • split()
    • replaceAll()

An array of

  • create
    • var list = [1, 2, 3];
    • var list = new List()
    • var list = const[1, 2, 3]Immutable array
  • Commonly used method
    • length()
    • add() insert() remove() clear()
    • indexOf() lastIndexOf()
    • sort()
    • subList()
    • asMap()The subscript for key
    • forEach()
    • shuffle()

Key/value pair

  • create
    • Map map = {"key" : "value"}
    • Map map = new Map(); map["key"] = "value";

dynamic

  • dynamicTells the compiler not to do type checking
  • When a method that does not exist is called, it executesnoSuchMethod()Method, throwNoSuchMethodError